检测是否重复:

     public static boolean checkDifferent(String iniString) {
boolean isbool = false;
char[] chars = iniString.toCharArray();
for (int i = 0; i < chars.length; i++) {
for (int j = i + 1; j < chars.length; j++) {
if (chars[i] == chars[j]) {
isbool = true;
return isbool;
} else {
isbool = false;
}
}
}
return isbool;
}

输出重复:

 public static void repeat_find( String s) {
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
for (int j = i + 1; j < s.length(); j++) {
if (s.charAt(j) == c) {
System.out.println("找到了重复的字符为:" + c);
}
}
}
}
04-15 19:41