問題はint [][]tam = new int [a][b]
です。その行だけです。私はJavaを初め、C++のバックグラウンドから来ています。ArrayIndexOutofBounds - help?
//"Exercitiul" 3
Scanner input = new Scanner(System.in);//instructiune scanner
DataInputStream dis4 = new DataInputStream(System.in);
DataInputStream dis5 = new DataInputStream(System.in);
String st1 = null;
String st2 = null;
try{
System.out.println("Introduceti numarul de Randuri");
st1 = dis4.readLine();
System.out.println("Introduceti numarul de Coloane");
st2 = dis5.readLine();
}
catch (IOException ioe) {
ioe.printStackTrace();
}
int a = Integer.parseInt(st1);
int b = Integer.parseInt(st2);
int [][]tam = new int[a][b];
System.out.println("Verificare " + tam[a][b]);
System.out.println("Introduceti Elementele Matricei ");
for (int m=0 ; m < tam.length ; m++)
for (int n=0 ; n < tam[i].length ; n++){
tam[m][n] = input.nextInt();//instructiune scanner
}
System.out.println("Matricea A: ");
for (int m=0 ; m < tam.length ; m++)
{ System.out.println();
for (int n=0 ; n < tam[i].length ; n++)
System.out.print(tam[m][n]+" ");
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at Program.main(Program.java:95)
ここで、i変数はどこから来ますか?それが使用される2つの場所にmがあるべきではありませんか? – MarianP