字體:小 中 大 |
|
|
|
| 2008/05/25 22:06:39瀏覽1676|回應1|推薦0 | |
| public class CreatePassWord{ public static void main(String args[]){ //產生亂數密碼 int[] word = new int[8]; int mod; for(int i = 0; i < 8; i++){ mod = (int)((Math.random()*7)%3); if(mod ==1){ //數字 word[i]=(int)((Math.random()*10) + 48); }else if(mod ==2){ //大寫英文 word[i] = (char)((Math.random()*26) + 65); }else{ //小寫英文 word[i] = (char)((Math.random()*26) + 97); } } StringBuffer newPassword = new StringBuffer(); for(int j = 0; j < 8; j++){ newPassword.append((char)word[j]); } System.out.println(newPassword); } } |
|
| ( 知識學習|其他 ) |











