Skip to content

Commit 6008fbf

Browse files
committed
feat(strings): Add ReverseStringUsingStack to reverse strings using stack
1 parent 0c4e319 commit 6008fbf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.Scanner;
44
import java.util.Stack;
55

6-
public class ReverseStringUsingStack {
6+
public final class ReverseStringUsingStack {
77

88
/**
99
* Main method to take user input and print the reversed string.
@@ -19,6 +19,10 @@ public static void main(String[] args) {
1919
System.out.println("Reversed String : " + reverse(str));
2020
sc.close();
2121
}
22+
// Private constructor to hide implicit public one
23+
private ReverseStringUsingStack() {
24+
throw new UnsupportedOperationException("Utility class");
25+
}
2226

2327
/**
2428
* Reverses a string using a stack.

0 commit comments

Comments
 (0)