第一种方法
public static void main(String[] args){
String[] b = {"公共的", "私有的", "受保护的"};
Random rand = new Random();
int num = rand.nextInt(3);
System.out.println(b[num]);
}
第二种方法
public class Test2 {
public static void main(String[] args) {
String a="a,b,c,d";
String c="a b c d e f g h i j k l m n o p q";
String[] b=a.split(",");
String[] d=c.split("\\s");
int str= (int) (Math.random()*d.length);
System.out.println(d[str]);
}
}