좋아, 그럼 내 내부 루프에 대한 약간의 논리 오류가 있다고 말했습니다. 외관상으로는 [2] [2] 배열이 2X3 요소 또는 3X2 요소 였을 경우 누군가가이 약간의 문제를 해결하는 방법을 말해 줄 수 있습니까? 배열의 for 루프와의 논리적 오류
for (int i = 0; i < country.length; i++) {
// note the change here
for (int j = 0; j < country[i].length; j++) {
// ...
}
}
그렇지 않으면, 내부 루프만큼 그것을 필요로 카운트하지 않습니다에
public static void dispArr(String [][] country){
for(int i= 0; i<country.length; i++){ // both for loops count from 0 to 1 which are the only numbers required for this given array
for(int j= 0; j<country.length; j++){
System.out.print(country[i][j]); //this will output [0][0],[0][1],[1][0] and[1][1] as identified above.
}
System.out.println("\n"); //create space between both
}
}
내부 루프에'country [i] .length' 시도 –
대단히 감사합니다! – user3111329