import java.util.Scanner;
class DianMing
{
public static void DianMing(String[] name)
{
int a = 1;
do
{
int index =(int) (Math.random()*5);
System.out.println(name[index]);
Scanner sc = new Scanner(System.in);
System.out.println("是否继续点名? 1:继续;任意键:结束");
a = sc.nextInt();
}
while (a==1);
}
}
class DianMingTest
{
public static void main(String[] args)
{
String[] name = new String[5]{"张三","李四","王二","刘七","郑八"};
DianMing d = new DianMing();
d.DianMing(name);
}
} |
|