https://www.cnblogs.com/libin6505/p/10155657.html
package com.test1;
public class Test3 {
public static void main(String[] args) {
//需要生成幾位
int n = 1;
//最終生成的字符串
String str = "";
for (int i = 0; i < n; i++) {
str = str + (char)(Math.random()*26+'a');
}
System.out.println(str);
}
}
/*
特別注意的點:
1, ‘A’ 是隨機生成大寫的26個隨機字母
2, ‘a’ 是隨機生成小寫的26個隨機字母
3, n 的值變化,是生成多少位隨機數 n = 1,則隨機生成一位; n= 2,則隨機生成2位,依次類推…
*/
