各位大大好:
求救一下,關於深入淺出JAVA第二版這本書,看到第37頁,
遇到一個難題,(書頁快照:
![]()
)
我寫了一個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撰寫