File tree Expand file tree Collapse file tree 1 file changed +5
-23
lines changed
src/main/java/com/thealgorithms/strings Expand file tree Collapse file tree 1 file changed +5
-23
lines changed Original file line number Diff line number Diff line change 11package com .thealgorithms .strings ;
22
3- import java .util .Scanner ;
4-
3+ /**
4+ * Checks if one string is a rotation of another string.
5+ */
56public class StringRotation {
67
78 /**
8- * Checks if str2 is a rotation of str1
9+ * Checks if str2 is a rotation of str1.
10+ *
911 * @param str1 Original string
1012 * @param str2 String to check for rotation
1113 * @return true if str2 is a rotation of str1, false otherwise
@@ -22,24 +24,4 @@ public static boolean isRotation(String str1, String str2) {
2224 String concatenated = str1 + str1 ;
2325 return concatenated .contains (str2 );
2426 }
25-
26- public static void main (String [] args ) {
27- Scanner scanner = new Scanner (System .in );
28-
29- System .out .print ("Enter first string: " );
30- String str1 = scanner .nextLine ();
31-
32- System .out .print ("Enter second string: " );
33- String str2 = scanner .nextLine ();
34-
35- boolean result = isRotation (str1 , str2 );
36-
37- if (result ) {
38- System .out .println ("\" " + str2 + "\" is a rotation of \" " + str1 + "\" ." );
39- } else {
40- System .out .println ("\" " + str2 + "\" is NOT a rotation of \" " + str1 + "\" ." );
41- }
42-
43- scanner .close ();
44- }
4527}
You can’t perform that action at this time.
0 commit comments