public class Doobe {
public static void main(String[] args)
{
String[] wordListOne = {"24/7", "B-To-B", "smart", "win-win"};
String[] wordListTwo = {"sticky", "branded", "focused", "aligned"};
String[] wordListThree = {"process", "solutino", "space", "vision"};
//计算字符数组长度
int oneLength = wordListOne.length;
int twoLength = wordListTwo.length;
int threeLength = wordListThree.length;
//产生随机数
int rand1 = (int)(Math.random() * oneLength);
int rand2 = (int)(Math.random() * twoLength);
int rand3 = (int)(Math.random() * threeLength);
//组合语句
String phtase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
//输出
System.out.println("what we need is a " + phtase);
}
}
JAVA生成随机语句
最新推荐文章于 2022-12-11 11:52:09 发布