int[][] input = new int[3][];
этот тип массива называются рваный массив. Вы должны определить размер столбец для каждого строка. как это:
input[0]=new int[2];//for row 1 (row 1 contain 2 column)
input[1]=new int[5];//for row 2 (row 2 contain 5 column)
input[2]=new int[1];// for row 3 (row 3 contain 1 column)
так определить размер столбца для каждой строки, как вы хотите
/* Рваные массивы многомерные массивы, в которых строка имеет различное ЧИСЛО перевалов. */
class Ragged
{
public static void main(String args[])
{
//declaration of a ragged array
int arr[][] = new int[3][];
//declaration of cols per row
arr[0] = new int[4];
arr[1] = new int[2];
arr[2] = new int[3];
int i, j;
for(i =0; i< arr.length; i++)
{
for(j =0 ; j< arr[i].length; j++)
{
arr[i][j] = i + j+ 10;
}
}
for(i =0; i< arr.length; i++)
{
System.out.println();//skip a line
for(j =0 ; j< arr[i].length; j++)
{
System.out.print(arr[i][j] + " ");
}
}
//-------------more----------------
int temp[];//int array reference
//swap row2 and row3 of arr
temp = arr[1];
arr[1] = arr[2];
arr[2] = temp;
System.out.println();//skip a line
for(i =0; i< arr.length; i++)
{
System.out.println();//skip a line
for(j =0 ; j< arr[i].length; j++)
{
System.out.print(arr[i][j] + " ");
}
}
}//main
}//class
/* объявить рваный массив определить мульти двумерный массива с Валом последнего измерения отсутствует.
Явное определение размера последнего измерения для всех строк. */
Вы не инициализировали второе измерение массива. 'int [] [] input = new int [3] [3];' –
duplicate: http://stackoverflow.com/questions/12231453/creating-two-dimensional-array –
@ user3167973, если мой ответ будет полезен, вы можете выберите мой ответ – Ashish