22 lines
528 B
Java
22 lines
528 B
Java
// housekeeping/SimpleConstructor.java
|
|
// (c)2016 MindView LLC: see Copyright.txt
|
|
// We make no guarantees that this code is fit for any purpose.
|
|
// Visit http://OnJava8.com for more book information.
|
|
// Demonstration of a simple constructor
|
|
|
|
class Rock {
|
|
Rock() { // This is the constructor
|
|
System.out.print("Rock ");
|
|
}
|
|
}
|
|
|
|
public class SimpleConstructor {
|
|
public static void main(String[] args) {
|
|
for(int i = 0; i < 10; i++)
|
|
new Rock();
|
|
}
|
|
}
|
|
/* Output:
|
|
Rock Rock Rock Rock Rock Rock Rock Rock Rock Rock
|
|
*/
|