-2
화면에 인쇄되는 간단한 2D 배열이 있습니다.왜 내 2D 배열을 실행할 수 없습니까?
제 문제는 코드가 제대로 컴파일되지 않는다는 것입니다. 제가 잘못하고있는 것은 무엇입니까?
내 비 작동 코드는 다음과 같습니다
/* This program initialises two-dimensional arrays.......*/
/* ********************************************************/
public class InitArray4
{
// create and output two-dimensional arrays
public static void main(String[] args)
{
int[][] array1 = { { 1, 2, 3 }, { 4, 5, 6 } };
int[][] array2 = { { 1, 2 }, { 3 }, { 4, 5, 6 } };
System.out.println("Values in array1 by row are");
outputArray(array1); // displays array1 by row
System.out.println("\nValues in array2 by row are");
outputArray(array2); // displays array2 by row
} // end main
// output rows and columns of a two-dimensional array
public static void outputArray()
{
// loop through array's rows
for (int row = 0; row < array.length; row++)
{
// loop through columns of current row
for (int column = 0; column < array[ row ].length; column++)
System.out.printf("%d ", array[ row ][ column ]);
System.out.println(); // start new line of output
} // end outer for
} // end method outputArray
} // end class InitArray
감사에 인수를 추가! –
내 초심자 오류 –