ある文字列がその文字列の回転語であるかどうかを判断する


import java.util.Scanner;

public class TreePrinter {
	static TreePrinter mm = new TreePrinter();

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String A = scanner.nextLine();
		String B = scanner.nextLine();
		System.out.println(mm.chkRotation3(A, A.length(), B, B.length()));
	}

	//   
	public boolean chkRotation1(String A, int lena, String B, int lenb) {
		// write code here
		if (lena != lenb) {
			return false;
		}
		String C = A + A;
		char[] bb = B.toCharArray();
		char[] cc = C.toCharArray();
		for (int i = 0; i < cc.length; i++) {
			for (int j = 0; j < bb.length; j++) {
				if (cc[i] == bb[j]) {
					return true;
				}
			}
		}
		return false;
	}
	
	//   
	public boolean chkRotation2(String A, int lena, String B, int lenb) {
		if(lena!= lenb || A== null || B==null){
			return false;
		}
		String C = A+A;
		if(C.contains(B)){
			return true;
		}
		return false;
	}
	
	//   
	public boolean chkRotation3(String A, int lena, String B, int lenb) {
		if(lena!= lenb || A== null || B==null){
			return false;
		}
		String C = A+A;
		for(int i=0;i