OnJava8-Examples/housekeeping/SimpleConstructor.java
2015-11-03 12:00:44 -08:00

19 lines
369 B
Java

// housekeeping/SimpleConstructor.java
// Demonstration of a simple constructor.
class Rock {
Rock() { // This is the constructor
System.out.println("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
*/