需求描述:
生成6位随机密码。
/**
* 生成密码,如需要数字、特殊字符,在数组元素中添加即可
* @return
*/
public String getPasswd(){
String[] pa = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
StringBuffer sb = new StringBuffer("");
for (int i = 0; i < 6; i++) {
sb.append(pa[(Double.valueOf(Math.random() * pa.length).intValue())]);
}
return sb.toString();
}