关于thinking in java 中的一些菜鸟问题
//:c04:SimpleConstructor.java// Demonstration of a simple constructor.import com.bruceeckel.simpletest.*;class Rock{ Rock(){//This is a constructor System.out.println("Creating Rock"); }}public class SimpleConstructor{ static Test monitor = new Test(); public static void main(String[] args){ for(int i = 0;i < 10;i++) new Rock(); monitor.expect(new String[] { "Creating Rock", "Creating Rock", "Creating Rock", "Creating Rock", "Creating Rock", "Creating Rock", "Creating Rock", "Creating Rock", "Creating Rock", "Creating Rock" }); }} ///:~
//: initialization/SimpleConstructor.java// 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*///:~