int n = sc.nextInt();
char[][] original = new char[n][n];
char [][] result = new char[n][n];
String line;
for (int i = 0; i < n; i++) {
line = sc.nextLine();
System.out.println(line);
for (int u = 0; u < n; u++) {
original[i][u] = line.charAt(u);
}
}
for (int i = 0; i < n; i++) {
line = sc.nextLine();
for (int u = 0; u < n; u++) {
result[i][u] = line.charAt(u);
}
}
我有这样的档案:
2
ha
ah
lo
ol
我对背信弃义的N型号,然后是两个N*N型号。
我正试图把它们读到两个阵列中,但我发现这一错误:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:695) at transform.main(transform.java:25)
第25条是:
original[i][u] = line.charAt(u);
I just don t get it, I think I m doing everything just fine. Any ideas? Thank you!