【发布时间】:2020-03-30 15:35:48
【问题描述】:
我想创建一个 2D 字符串数组,它存储作为键盘输入给出的名称和地址。 eg:姓名1地址1; 名称 2 地址 2;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[][] array = new String[3][2];
for (int i = 0; i < 3; i++)
{
for(int j = 0; j < 2; j++)
{
array[i][j] = sc.nextLine();
}
System.out.println(array[0][0]);
}
}
在这里我想打印一个要求输入姓名的语句 例如。 System.out.println("请输入姓名:"); 之后我想写另一条语句要求输入地址 eg.System.out.println("输入地址"); 但我不知道如何在二维数组中做到这一点
【问题讨论】: