Skip to content

Commit 4aa527e

Browse files
committed
Fix formatting for ReverseStack and test files
1 parent 1546b15 commit 4aa527e

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

src/main/java/com/thealgorithms/datastructures/stacks/ReverseStack.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,18 @@ private ReverseStack() {
3737
*
3838
* @param stack the stack to reverse; should not be null
3939
*/
40-
public static void reverseStack(Stack<Integer> stack) {
41-
if (stack == null) {
42-
throw new IllegalArgumentException("Stack cannot be null");
43-
}
44-
if (stack.isEmpty()) {
45-
return;
46-
}
47-
48-
int element = stack.pop();
49-
reverseStack(stack);
50-
insertAtBottom(stack, element);
51-
}
40+
public static void reverseStack(Stack<Integer> stack) {
41+
if (stack == null) {
42+
throw new IllegalArgumentException("Stack cannot be null");
43+
}
44+
if (stack.isEmpty()) {
45+
return;
46+
}
5247

48+
int element = stack.pop();
49+
reverseStack(stack);
50+
insertAtBottom(stack, element);
51+
}
5352

5453
/**
5554
* Inserts the specified element at the bottom of the stack.

src/test/java/com/thealgorithms/datastructures/stacks/ReverseStackTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010
class ReverseStackTest {
1111

1212
@Test
13-
void testReverseNullStack() {
14-
assertThrows(IllegalArgumentException.class,
15-
() -> ReverseStack.reverseStack(null),
16-
"Reversing a null stack should throw an IllegalArgumentException.");
17-
}
18-
13+
void testReverseNullStack() {
14+
assertThrows(IllegalArgumentException.class, () -> ReverseStack.reverseStack(null), "Reversing a null stack should throw an IllegalArgumentException.");
15+
}
1916

2017
@Test
2118
void testReverseEmptyStack() {

0 commit comments

Comments
 (0)