在这里插入代码片public class expert{
public static void main(String[] args) {
String[] wordlistone= {"one","two"
,"three","four"};
String[] wordlisttwo= {"empowered","sticky","Every Thing is Possble"};
String[] wordlistthree = {"Process","Interesting","Success","Failure"};
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 words = wordlistone[rand1]+" "+ wordlisttwo[rand2]+
" "+wordlistthree[rand3];
System.out.println(words);
}
}
1.(int)(Math.random()*numbers) 可以表示随机数;
2.定义字符数组用String 注意大小写;
3.数组.length 可以计算数组的空间数量
4.random()这个方法可以返回一个介于0到1之间的小数
5.(int)可以取整