Skip to content

Commit ff9573a

Browse files
fix: remove main method and add unit tests for StringRotation
1 parent 279a307 commit ff9573a

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed
Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.thealgorithms.strings;
22

3-
import java.util.Scanner;
4-
3+
/**
4+
* Checks if one string is a rotation of another string.
5+
*/
56
public 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
}

0 commit comments

Comments
 (0)