File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
src/main/java/com/thealgorithms Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ public static String reverse(String str) {
2222 return str ;
2323 }
2424 // Push each character of the string onto the stack
25- for (char ch : str .toCharArray ()) {
26- stack .push (ch );
25+ for (char i : str .toCharArray ()) {
26+ stack .push (i );
2727 }
2828 // Pop each character from the stack and append to the StringBuilder
2929 while (!stack .isEmpty ()) {
Original file line number Diff line number Diff line change @@ -76,13 +76,14 @@ public static String reverse4(String str) {
7676 return str ;
7777 }
7878 // Push each character of the string onto the stack
79- for (char ch : str .toCharArray ()) {
80- stack .push (ch );
79+ for (char i : str .toCharArray ()) {
80+ stack .push (i );
8181 }
8282 // Pop each character from the stack and append to the StringBuilder
8383 while (!stack .isEmpty ()) {
8484 reversedString .append (stack .pop ());
8585 }
8686 return reversedString .toString ();
8787 }
88+
8889}
You can’t perform that action at this time.
0 commit comments