交作业冲鸭!
package imooc3_4_3;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.ArrayList;
public class HomeWork3_6_5 {
public static List<String> stringList;
public HomeWork3_6_5() {
stringList=new ArrayList<String>();
}
public void addList() {
Random random=new Random();
int a=(int)'a';
int z=(int)'z';
for(int i=1;i<=10;i++)
{
int numberChracter=random.nextInt(10);
String ch2="";
for(int j=1;j<=numberChracter;j++) {
char chracter=(char)(a+random.nextInt(z-a));
String ch1=String.valueOf(chracter);
ch2=ch2+ch1;
}
stringList.add(ch2);
}
}
public void show(List<String> stringList) {
for (String string : stringList) {
System.out.println("元素:"+string);
}
}
public static void main(String[] args) {
HomeWork3_6_5 hw=new HomeWork3_6_5();
hw.addList();
hw.show(stringList);
}
}