我需要用户输入3个用空格分隔的名称,例如:
Please enter 3 names: name1 name2 name3
然后我想将它存储到数组中,其中包含3个字符串元素作为这3个名称,如何做到这一点,请建议我一些java中的STRING方法,因为我经常使用C++,< strong>我不是要代码,谢谢!
String array[] = new String[3];
System.out.print("Please enter 3 names: ");
Scanner in = new Scanner(System.in);
String input = in.nextLine();
//do domething
最佳答案
这是一个完美的地方
关于java - 将行数据读取到字符串数组中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10903444/