收集面试题(七)(查看是否包含字符串)

字符串循环比较
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String root = "AABBCD";
		String compare = "CDAA";
		System.out.println(compareString(root, compare));

	}

	public static boolean compareString(String root, String compare) {

		if (compare.length() > root.length()) {
			return false;
		}
		String fatherStr = root.concat(root);

		if (fatherStr.contains(compare)) {
			return true;
		}
		return false;
	}

你可能感兴趣的:(java,面试)