50,528
社区成员
发帖
与我相关
我的任务
分享
import java.util.Random;
public class Test01 {
static final char[] VOWEL_ARR = new char[]{'A','E','I','O','U'};
public static void main(String[] args) {
int count = 0;
Random random = new Random();
do {
int seed = random.nextInt(26);
char c = (char) ('A' + seed);
if(!isVowel(c)) {
System.out.print(c);
++count;
}
} while(count < 26);
}
static boolean isVowel(char c) {
for (int i = 0;i < VOWEL_ARR.length;++i) {
if(c == VOWEL_ARR[i]) {
return true;
}
}
return false;
}
}