OnJava8-Examples/housekeeping/SimpleConstructor.java
2015-12-15 11:47:04 -08:00

22 lines
547 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://mindviewinc.com/Books/OnJava/ 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
*/