求大神帮我解决下这道java题目?

2025-01-06 12:30:03
推荐回答(3个)
回答1:

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

String[][] data = new String[3][2];

for(int i = 0;i < 3;i++)

for(int j = 0;j < 2;j++)

data[i][j] = in.next();

for(int i = 0;i < 3;i++)

{

for(int j = 0;j < 2;j++)

System.out.print(data[i][j] + "  ");

System.out.println();

}

}


回答2:

String strs[][]=new String[3][2];
strs[0]=new String[2];
strs[1]=new String[2];
strs[2]=new String[2];
Scanner scan=new Scanner(System.in);
for(int i=0;ifor(int j=0;jSystem.out.println("请输入名字:");
String name=scan.nextLine();
strs[i][j]=name;
}
}
System.out.println("你输入的名字是:");
for(int i=0;i for(int j=0;j
System.out.print(strs[i][j]);
}
System.out.println();
}
放到main方法中执行

回答3:

String[][] m=new String[3][2];
for(int i=0;i for(int i2=0;i2 m[i][i2]="XX";
}
}
for(int i=0;i