Skip to content

Commit e091e22

Browse files
committed
Refactored ReverseStringUsingStack utility for reversing strings using stack
1 parent 4d939c3 commit e091e22

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/com/thealgorithms/strings/ReverseString.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public static String reverse3(String string) {
6666
* and then pops them off to create the reversed string.
6767
*/
6868
public static String reverse4(String str) {
69+
// Check if the input string is null
6970
if (str == null) {
7071
throw new IllegalArgumentException("Input string cannot be null");
7172
}
@@ -85,4 +86,4 @@ public static String reverse4(String str) {
8586
}
8687
return reversedString.toString();
8788
}
88-
}
89+
}

0 commit comments

Comments
 (0)