OnJava8-Examples/housekeeping/SimpleConstructor.java

20 lines
408 B
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// housekeeping/SimpleConstructor.java
2015-06-15 17:47:35 -07:00
// <20>2015 MindView LLC: see Copyright.txt
// 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();
}
2015-09-07 11:44:36 -06:00
}
/* Output:
2015-06-15 17:47:35 -07:00
Rock Rock Rock Rock Rock Rock Rock Rock Rock Rock
2015-09-07 11:44:36 -06:00
*/