java输入不换行,按空格输入下一个数字
public static void main(String[] args) {
int[][] a = new int [2][3];
try {
Scanner s = new Scanner(System.in);
for (int i = 0 ; i < 2; i++) {
System.out.println("请输入:");
String s1 = s.next();
String s2 = s.next();
String s3 = s.next();
a[i][0] = Integer.parseInt(s1);
a[i][1] = Integer.parseInt(s2);
a[i][2] = Integer.parseInt(s3);
}
for (int i = 0 ; i < a.length; i++ ) {
for (int j = 0; j < a[i].length; j++) {
System.out.println("a[" + i + "][" + j + "] = " + a[i][j]);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}