我想让用户将字符串分配给 2 个数组。然后我希望他能够在分配后键入一个数字以提取分配给字符串的值。
import java.util.Scanner;
public class Main {
public static void main (String[]args) {
Scanner keyboard = new Scanner(System.in);
String customerList[] = new String[2];
customerList[1] = keyboard.nextLine();
customerList[2] = keyboard.nextLine();
System.out.println("Which array value would you like to see?");
int listNum = keyboard.nextInt();
System.out.println(customerList[listNum]);
}
}