62,623
社区成员
发帖
与我相关
我的任务
分享public class test1 {
public void travese(String str) {
int offset = 0;
int len = str.length();
for (int i = len / 2; i >0; i--) {
while (offset + 2 * i <=len) {
if (str.substring(offset, offset + i).equals(
str.substring(offset + i, offset + 2 * i))) {
System.out.println(str.substring(offset, offset + i));
}
offset++;
}
offset=0;
}
}
public static void main(String args[]) {
String test = "adadcdadcd";
new test1().travese(test);
}
}