1

这是在main()方法中:

Movie[] list = new Movie[6];

list[0] = new Animated(.25, 700.000, "Mulan", "Barry Cook", 1998, 15.000);
list[1] = new Animated(.23, 45.000, "TMNT", "Steve Barron", 1990, 12.000);
list[2] = new Documentary(12, 7.000, "Nixon", "Oliver Stone", 1995, 50.000);
list[3] = new Documentary(10, 4.500, "JFK", "Oliver Stone", 1991, 35.000);
list[4] = new Drama(3.500, 8.25, "Belly", "Hype Williams", 1998, 20.000);
list[5] = new Drama(4.500, 9.00, "42", "Brian Helgeland", 2013, 16.000);

System.out.print(menu());
System.out.print("Select and menu option 1-5: ");
choice = input.nextInt();
do
{
    switch(choice)
    {
        case 1: movieList(list);
        break;

我正在调用movieList(list)外部类中存在的方法main

public static void movieList(Movie[] a)
{
    System.out.printf("\n\n%-10s %-10s %-10s %-10s %-10s", "TITLE", "YEAR",
    "REVENUE", "PROFIT", "CATEGORY");
    System.out.printf("\n\n%-10s", Movie[0].getTitle());
}

这是我正在调用的方法case 1,我一直在尝试使用一个参数,但我在 Movie 上的指针出现“找不到符号”错误。我一直在寻找,我开始认为我不能以这种方式访问​​这个值。

4

1 回答 1

4

Movie[]方法中参数的名称movieLista,因此请尝试使用a[0].getTitle()而不是Movie[0].getTitle()。方法中的参数总是通过它的名字来访问,而不是它的类型。

于 2013-04-20T05:41:06.423 回答