本文为在How2j的学习总结,只代表个人见解,如有不妥,望指出以便更正。
问题描述:创建一个长度是1000的字符串数组,使用长度是2的随机字符填充该字符串数组,统计这个字符串数组里重复的字符串有多少种。
注:需要去除重复次数大于2的情况。
package test;
/*创建一个长度是1000的字符串数组
使用长度是2的随机字符填充该字符串数组
统计这个字符串数组里重复的字符串有多少种*/
public class Test_String_compare_exercise {
// 随机字符串产生方法
private static String getrandomstr(int length) {
char[] cs = new char[length];
String pool = "";
for(short i='0'; i<='9'; i++) {
pool = pool + (char)i;
}
for(short i='A'; i<='Z'; i++) {
pool = pool + (char)i;
}
for(short i='a'; i<='z'; i++) {
pool = pool + (char)i;
}
for(int j=0; j<cs.length; j++) {
int index =</