檢查一個字串是否為另一字串的迴圈。


要找到一個字串是另一個字串的迴圈,將第一個字串連線到它本身兩次,並找到天氣

示例

 動態演示

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");
      }
   }
}

更新於: 30-7 月 -2019

398 次觀看

開啟您的 職業生涯

完成課程即可獲得認證

開始吧
廣告