用Java编写一个,随机选择一个历史美女的代码案例,要求美女数量20个
时间: 2024-06-11 14:05:51 浏览: 151
产品开发+社区运营+2000个美女头像+产品上线需要的头像
import java.util.Random;
public class ChooseBeauty {
public static void main(String[] args) {
String[] beauties = {"貂蝉", "王昭君", "杨贵妃", "西施", "貂蝉", "王昭君", "杨贵妃", "西施", "貂蝉", "王昭君", "杨贵妃", "西施", "貂蝉", "王昭君", "杨贵妃", "西施", "貂蝉", "王昭君", "杨贵妃", "西施"};
Random rand = new Random();
int index = rand.nextInt(20);
System.out.println("今天我们选择的历史美女是:" + beauties[index]);
}
}
阅读全文