各位大大好:
求救一下,关于深入浅出JAVA第二版这本书,看到第37页,
遇到一个难题,(书页快照:http://ppt.cc/~jIG )
我写了一个class Movie一个class MovieTestDrive,
可是并没有书上的object1、2、3们,
怎么执行都只有一句话"Playing the Movie",
请问这是为什么呢??
第一个Class Movie
class Movie {
String title;
String genre;
int rating;
void playIt(){
System.out.println("Playing the movie");
}
}
第二个Class MovieTestDrive
public class MovieTestDrive {
public static void main(String[] args){
Movie one = new Movie();
one.title = "Gone with the Stock";
one.genre = "Tragic";
one.rating = -2;
Movie two = new Movie();
two.title = "Lost in Cubicle Space";
two.genre = "Comeby";
two.rating = 5;
two.playIt();
Movie three = new Movie();
three.title = "Byte Club";
three.genre = "Tragic but ultimately uplifting";
three.rating = 127;
}
}
PS:我是用Eclipse撰写