6 亿 VIP 文档下载 千万文档免费下 加入文库 VIP 本文免费下载
int count = 1;
for(String i:setStr){
System.out.print(i+" ");
if(count%4 == 0) {
System.out.println();
}
count++;
}
}
/**
* @param strLen:随机字符串的长度
*/
public static String randomStr(int strLen) {
char[] str = new char[strLen];
int i = 0;
while(i
int f = (int)Math.random()*3;
if(f == 0) {
str[i] = (char)('a' + Math.random()*26);
}else if(f == 1) {
str[i] = (char)('A' + Math.random()*26);
}else {
str[i] = (char)('0' + Math.random()*10);
}
i++;
}
return new String(str);
}
}
6.手动输入一个字符串,仅限小写字母,统计并输出每个字符在字符串中出现的次数,
并输出。提示(可以用 Map)