一维数组点名器:
public static void main(String[] agrs){
dainMing();
}
public static void dainMing() {
Scanner scanner = new Scanner(System.in);
Random random = new Random();
//把要被点名的人全部放入names数组中
String[] names = {"许嵩","徐良","小飞","汪苏泷","周润发","周杰伦",};
while (true) {
System.out.println("请输入你的选项:\n1:点名\n2:退出");
int tag = scanner.nextInt();
if (tag == 1) {
int i = random.nextInt(6);
System.out.println("请"+names[i]+"回答问题");
}else if(tag == 2) {
System.out.println("欢迎下次使用");
break;
}
}
}