一、直接上代码
public static String getRandStr(int num){
String strs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
StringBuffer buff = new StringBuffer();
for(int i=1;i<=num;i++){
char str = strs.charAt((int)(Math.random() * 26));
buff.append(str);
}
return buff.toString();
}