首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

关于thinking in java 中的一些初学者有关问题

2012-04-28 
关于thinking in java 中的一些菜鸟问题Java code//:c04:SimpleConstructor.java// Demonstration of a si

关于thinking in java 中的一些菜鸟问题

Java code
//: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"        });    }} ///:~


直接照书上抄的!

编译时出错啦!

就是那个包的问题:import com.bruceeckel.simpletest.*

还有就是static Test monitor = new Test();这句话是干什么用的呀!?

貌似没有Test类呀!

高人指教!

[解决办法]
莫非Thinking in java出第五版了?
我找到的第4版代码是这样的
Java code
//: 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*///:~ 

热点排行