如何使用带有字符串的scanner.in数组并选择一个随机字符串?

时间:2018-01-20 02:54:48

标签: arrays string random java.util.scanner

目标是使用切换命令从帽子中绘制随机名称

String[] names = sc.next(); // how do I create an array of names with user 
input? also, see case a.

case 'a':
System.out.println("\nPlease enter the names of the participants.");
final String[] names = {sc.next()}; 

/*how do I add multiple names in one 
line? or by pressing enter for each additional name?*/

break;

0 个答案:

没有答案