How to write user input 2D array?
问题 I am new to java. Trying to make this into a user input 2D array which is 4*4. But when I try scanner, the row and col always got messed up. public static void main(String[] args) { String array = "1 2 2 1,1 3 3 1,1 3 3 2,2 2 2 2"; int[][] input = parseInt(array, 4, 4); } And I also want the user input can output as: 1 2 2 1 1 3 3 1 1 3 3 2 2 2 2 2 Appreciate for everybody's help! 回答1: Try this one : public static void main(String args[]) { String array = "1 2 2 1,1 3 3 1,1 3 3 2,2 2 2 2";