62,635
社区成员




import java.util.Random;
/**
* 原理:
* A-Z在ASCII编码上是连续的,先求出'A'的二进制值,随机加上0-25即可得到A-Z中的随机字符
*
* @author jinxfei
*
*/
public class Test {
public static void main(String[] args){
Random rand=new Random(System.currentTimeMillis());
int aCode=(int)'A';
for(int i=0; i<100; i++){
int randNum=rand.nextInt(26);
int randChar=aCode+randNum;
System.out.println(Character.toString((char)randChar));
}
}
}
public class Test {
public static void main(String[] args) {
for (int i = 0; i < 26; i++) {
System.out.println((char) ((int) (Math.random() * 26 + 'a')));
}
}
}