BlueJ错误:不兼容的类型:java.lang.String无法转换为java.lang.String []

时间:2015-12-27 16:01:13

标签: java compiler-errors

嗨专家我是Java编程的新手,我决定学习它。 我正在使用Oracle页面中的学习Java教程来学习编码。

请帮助我了解如何更正我的代码以及我出错的地方

谢谢 这是我的代码:

public class Demo
{
    public static void main(String[] args) {

        String[][][] year11 ={
             {"Mr. ", "Miss. "}, *// this is where i had the error: incompatible  types: java.lang.String cannot be converted to java.lang.String[]*
             {"James", "Jude", "Samuel",
             "Sara", "Danielle", "Serah",
             "David", "Natalie", "Aubrey"},
             {"Year11_A", "Year10_A", "Year11_B", "Year10_A", "Year10_B"} 
            };
        char[] aGrade = {'A', 'B', 'C', 'D', 'U'};

        int[] numGrade = {100, 97, 87, 92, 67, 71, 56, 66, 87}; 

        System.out.println("Name:" + year11[0][0] + "Result: " + numGrade[4] +
                           "Grade: " + aGrade[3]);
        System.out.println("Name:" + year11[0][1] + "Result: " + numGrade[3] +
                           "Grade: " + aGrade[0]);
        System.out.println("Name:" + year11[0][2] + "Result: " + numGrade[2] +
                           "Grade: " + aGrade[1]);
        System.out.println("Name:" + year11[1][3] + "Result: " + numGrade[8] +
                           "Grade: " + aGrade[1]);
        System.out.println("Name:" + year11[1][4] + "Result: " + numGrade[5] +
                           "Grade: " + aGrade[2]);
        System.out.println("Name:" + year11[1][5] + "Result: " + numGrade[2] +
                           "Grade: " + aGrade[2]);
        System.out.println("Name:" + year11[0][6] + "Result: " + numGrade[1] +
                           "Grade: " + aGrade[1]);
        System.out.println("Name:" + year11[1][7] + "Result: " + numGrade[6] +
                           "Grade: " + aGrade[3]);
        System.out.println("Name:" + year11[1][8] + "Result: " + numGrade[7] +
                           "Grade: " + aGrade[3]);

    }

}

1 个答案:

答案 0 :(得分:1)

String[][][]是一个三维数组引用类型,但您要为其分配一个二维数组,这会让编译器感到困惑。 (它期待您拥有"Mr. "的另一个数组。)将其更改为String[][] year11 = {