怎么同时产生两个不同得随机数,谢谢!
Dao里面:
/**
* 初始密码
* @param id
* return
* @throws Exception
*/
public String getDefaultPassword() throws EsealException {
//Random ra = new Random();
//return ra.nextInt(666666);
String str="";
Random rand = new Random();
rand.setSeed(System.currentTimeMillis());
for(int i=0;i<6;i++){
str= str + rand.nextInt(10);//每次生成一位的随机数并加再str后面.这样不用考虑高位为0的情况
}
System.out.print("Radom::::::::::"+str);
return str;
}
Action里面:
//随机生成六位初始印章密码
String gpwd = dao.getDefaultPassword();
//随机生成六位初始挂失密码
String losspwd = dao.getDefaultPassword();
但是我现在必须同时初始化两个密码,为什么得到得两个初始化密码总是一样的,该怎么解决,谢谢!!!
请指教!!!