public class benxi {
public static void main(String[] args) {
//给俩个字符串 其中一个旋转 一直转 成另一个就输出true
//俩字符串
String stra = "adcb";
String strb = "cbad";
//调用方法
boolean check = check(stra, strb);
System.out.println(check);
}
//定义方法若干次调整比较的
public static boolean check(String stra,String strb){
for (int i = 0; i < stra.length(); i++) {
//stra进入这个旋转方法 就开始转了 然后必须得等于stra 要不然每次循环都是一样stra
stra= rotate(stra);
if (stra.equals(strb)){
return true;
}
}
return false;
}
//定义旋转的方法 用截取 把左边的移到右边
public static String rotate(String str) {
//取到第一个数
char c = str.charAt(0);
//取剩余的数
String s = str.substring(1);
//反转过来了
String result=s+c;
return result;
}
}