Mega Code Archive

 
Categories / Java / Class
 

Demonstration of a simple constructor

// : c04:SimpleConstructor.java // Demonstration of a simple constructor. // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002 // www.BruceEckel.com. See copyright notice in CopyRight.txt. class Rock {   Rock() { // This is the constructor     System.out.println("Creating Rock");   } } public class SimpleConstructor {   public static void main(String[] args) {     for (int i = 0; i < 10; i++)       new Rock();   } } ///:~