java 二维字符数组输入的方法有很多,这里简单介绍一种:
import java.util.Scanner; public class test{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); //n行 int m = scan.nextInt();//m列 String[] temp= new String[n+1]; //字符串数组做中间变量 for(int i = 0; i< n; i++) { temp[i] = scan.next(); } char[][] p = new char[n][m]; // temp字符串数组转为二维数组p[n][m]; for(int i = 0; i<n; i++) { for(int j = 0; j< m; j++) { p[i][j] = temp[i].charAt(j); System.out.println(p[i][j]); } } } }