标签:style blog ar color sp for java 数据 div
package henu.swp.uill; import java.util.ArrayList; import java.util.List; import java.util.Random; public class AddUser { public static void main(String[] args) { getNames(10); } public static List<String> getNames(int num){ List<String> names = new ArrayList<String>() ; char[] firstname = { ‘赵‘ ,‘钱‘ ,‘孙‘, ‘李‘, ‘周‘, ‘吴‘ ,‘郑‘, ‘王‘ ,‘冯‘, ‘陈‘, ‘褚‘ ,‘卫‘ ,‘蒋‘, ‘沈‘ , ‘韩‘ , ‘杨‘, ‘朱‘ ,‘秦‘ , ‘尤‘ , ‘许‘ , ‘何‘ , ‘吕‘ , ‘施‘ , ‘张‘ , ‘孔‘ , ‘曹‘ , ‘严‘ , ‘华‘ , ‘金‘ , ‘魏‘ , ‘陶‘ , ‘姜‘, ‘戚‘ , ‘谢‘ , ‘邹‘ , ‘喻‘ , ‘柏‘ , ‘水‘ , ‘窦‘ , ‘章‘ , ‘云‘ , ‘苏‘ , ‘潘‘ , ‘葛‘ , ‘奚‘ , ‘范‘ , ‘彭‘ , ‘郎‘, ‘鲁‘ , ‘韦‘ , ‘昌‘ , ‘马‘ , ‘苗‘ , ‘凤‘ , ‘花‘ , ‘方‘ , ‘俞‘ , ‘任‘ , ‘袁‘ , ‘柳‘ , ‘酆‘ , ‘鲍‘ , ‘史‘ , ‘唐‘ } ; char[] lastname ={‘约‘ , ‘翰‘ , ‘威‘ , ‘尔‘ , ‘金‘ , ‘斯‘ , ‘主‘ , ‘教‘ , ‘就‘ , ‘在‘ , ‘书‘ , ‘中‘ , ‘描‘ , ‘写‘ , ‘了‘ , ‘人‘ , ‘类‘ , ‘在‘ , ‘月‘ , ‘球‘ , ‘上‘ , ‘生‘ , ‘活‘ , ‘二‘ , ‘十‘ , ‘世‘ , ‘纪‘ , ‘五‘ , ‘六‘ , ‘十‘ , ‘年‘ , ‘代‘ , ‘美‘ , ‘国‘ , ‘政‘ , ‘府‘ , ‘提‘ , ‘出‘ , ‘了‘ , ‘许‘ , ‘多‘,‘与‘ , ‘月‘ , ‘球‘ , ‘相‘ , ‘关‘ , ‘的‘ , ‘方‘ , ‘案‘ } ; int flen = firstname.length ; int llen = lastname.length ; for (int i = 0; i < num; i++) { int findex = new Random().nextInt(flen) ; int lindex1 = new Random().nextInt(llen) ; int lindex2 = new Random().nextInt(llen) ; char[] newname = new char[3] ; newname[0] = firstname[findex] ; newname[1] = lastname[lindex1] ; newname[2] = lastname[lindex2] ; String str = new String(newname); System.out.println("生成的名字是:"+str); names.add(str); } return names ; } }
标签:style blog ar color sp for java 数据 div
原文地址:http://www.cnblogs.com/oaks/p/4173389.html