Tady to máš, ale je to hnůj...
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
int j = 0;
int i = 0;
int b = 1;
Scanner x;
x = new Scanner(System.in);
System.out.println("Zadejte počet řádků: ");
int a = x.nextInt();
int[][] pole = new int[a][j];
// ZÁPIS DO POLE
for (i = 0; i < pole.length; i++) {
b = 1;
System.out.println("Obsah řádku(ukončete nulou): ");
while (b != 0) {
b = x.nextInt();
if (j >= pole[i].length) {
pole = ensureRowCapacity(pole);
}
pole[i][j] = b;
j++;
}
j = 0;
}
// VÝPIS POLE
for (i = 0; i < pole.length; i++) {
for (j = 0; j < pole[i].length; j++) {
int c = pole[i][j];
System.out.print(c + " ");
}
System.out.println("");
}
}
private static int[][] ensureRowCapacity(int[][] array) {
int[][] ret = new int[array.length][array[0].length + 1];
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
ret[i][j] = array[i][j];
}
}
return ret;
}
}