-1
文字列とintを使って(2)2次元配列を作成しようとしていますが、後で並べ替えることができますコード。これは、これまでの私のコードであり、私は何をすべきかわからないコンパイルとイムしようとしたときにエラーが発生しておいてください。他のデータ構造については(2)6×3の2次元配列を作成する方法(文字列と整数を保持できる)
public class SchoolBus {
public static void main(String[] args) {
Student[][] students = new Student[6][3];
students[0][0] = "Mabel";
students[0][1] = new int[1];
students[0][2] = new Integer(2);
students[1][0] = "Dipper";
students[1][1] = new Integer(1);
students[1][2] = new Integer(4);
students[2][0] = "Sam";
students[2][1] = new Integer(1);
students[2][2] = new Integer(7);
students[3][0] = "Ian";
students[3][1] = new Integer(2);
students[3][2] = new Integer(3);
students[4][0] = "Jordan";
students[4][1] = new Integer(2);
students[4][2] = new Integer(6);
students[5][0] = "Steven";
students[5][1] = new Integer(2);
students[5][2] = new Integer(9);
System.out.println(student);
}
}
は、それが配列であることを_have_ていますか?これにはより良いデータ構造があります。 「関連する整数と文字列のコレクションを最善に保存するにはどうすればよいですか」という質問に答えることを希望しますか? –
また、クラス「Student」をどこかに定義したようです。私たちがあなたのためにより良い答えを生み出すことができるように、それを見ることは有益でしょう。 –
あなたの配列の型は 'Student'なので、それが保持するものです。 –