我必須從命令行獲取輸入并將它們分配給2X2陣列。Input = 1 2 3 4 (from cmd line)output = 1 2 3 4 int a[][] = new int[2][2]; // taking 2D array inputof size 2X2 from cmdline for(int i=0;i<a.length;i++){ for(int j=0;j<a[i].length;j++){ int n = Integer.parseInt(args[i]); a[i][j] = n; } } for(int i=0;i<args.length;i++){ for(int j=0;j<a[0].length;j++){ System.out.print(a[i][j]+" "); } }但是獲取輸出為:1 1 2 2
添加回答
舉報
0/150
提交
取消