获取随机字符串

来源:互联网 发布:模拟退火算法的应用 编辑:程序博客网 时间:2024/05/01 21:05
public class RandStrUtil {


public final static String EN_UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public final static String EN_LOWER = "abcdefghijklmnopqrstuvwxyz";
public final static String NUM = "1234567890";

//获取大写的方法,其他相同

public static String getEnUpper(int strLen) {
Random r=new Random();
String Upper="";
for(int i=0;i<strLen;i++){
Upper+=EN_UPPER.charAt(r.nextInt(EN_UPPER.length()));
}
return Upper;
}
}
原创粉丝点击