为什么我会收到错误???我用eclipse,报错
在 AcmeVideo.main(AcmeVideo.java:8) 的 Shopping_Booket.Movie_assign(Shopping_Booket.java:8) 的线程“主”java.lang.NullPointerException 中的异常
编码:
public class AcmeVideo {
public static void main(String[] args) {
Shopping_Booket shop = new Shopping_Booket();
shop.Movie_assign();
}
}
public class Shopping_Booket {
movie[] MovieArray = new movie[5];
public void Movie_assign() {
MovieArray[0].Assign("Batman Dark Knight Return", 8, 2012, 22);
MovieArray[1].Assign("Fringe", 9.2, 2008, 40);
MovieArray[2].Assign("V for Vandetta", 8, 2005, 28);
MovieArray[3].Assign("X man First Class", 7, 2005, 30);
MovieArray[4].Assign("Hulk", 8.5, 2000, 16);
System.out.println(MovieArray[2].Title);
}
}
public class movie {
public String Title;
public double Rating;
public int Year;
public double Price;
public void Assign(String title, double rating, int year, double price) {
this.Title = title;
this.Rating = rating;
this.Year = year;
this.Price = price;
}
public void Displayİnfo() {
System.out.println("Title = " + Title);
System.out.println("Year = " + Year);
System.out.println("Rating = " + Rating);
System.out.println("Price = " + Price);
System.out.println("-------------------------------------");
}
}