檢查一個字串是否為另一字串的迴圈。
要找到一個字串是另一個字串的迴圈,將第一個字串連線到它本身兩次,並找到天氣
示例
public class Sample { public static void main(String args[]){ String str1 = "gala"; String str2 = "alag"; String s3 = str1+str1; if(s3.contains(str2)) { System.out.println("str1 is rotation of str2"); } else { System.out.println("str1 is not rotation of str2"); } } }
廣告