code:
private boolean isUserIdHaveSameNum(String str) { int num = 5; char[] chars = str.toCharArray(); int count = 0; for (int i = 0; i < chars.length - 1; i++) { if (chars[i] == chars[i + 1]) { count++; } else { count = 0; } if (count >= (num - 1)) { return true; } } return false; }
输入:12888885 > true 输入:12234568 > false 输入:55555 > true