File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed
main/java/com/thealgorithms/stacks
test/java/com/thealgorithms/stacks Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -63,9 +63,9 @@ public T pop() throws NoSuchElementException {
6363 throw new NoSuchElementException ();
6464 }
6565
66- T removed = top .element ; //Get the last inserted element before removing it
66+ T removed = top .element ; // Get the last inserted element before removing it
6767
68- top = top .next ; //Set the second to last element at the top
68+ top = top .next ; // Set the second to last element at the top
6969
7070 size --;
7171
@@ -84,11 +84,11 @@ public void push(T element) {
8484 Node next ;
8585
8686 if (top != null ) {
87- next = top ; //Save the current top node
87+ next = top ; // Save the current top node
8888
89- top = node ; //Update the newest node
89+ top = node ; // Update the newest node
9090
91- top .next = next ; //Make the new node point to the old node
91+ top .next = next ; // Make the new node point to the old node
9292 } else {
9393
9494 top = node ;
Original file line number Diff line number Diff line change 11package com .thealgorithms .stacks ;
22
3+ import java .util .NoSuchElementException ;
34import org .junit .jupiter .api .Assertions ;
45import org .junit .jupiter .api .BeforeEach ;
56import org .junit .jupiter .api .Test ;
67
7- import java .util .NoSuchElementException ;
8-
98class StackUsingLinkedListTest {
109
1110 private StackUsingLinkedList <Integer > linkedStack ;
@@ -36,7 +35,7 @@ void pop() {
3635
3736 linkedStack .pop ();
3837
39- Assertions .assertThrows (NoSuchElementException .class , () -> linkedStack .pop ()); //Cannot pop from an empty stack
38+ Assertions .assertThrows (NoSuchElementException .class , () -> linkedStack .pop ()); // Cannot pop from an empty stack
4039 }
4140
4241 @ Test
@@ -49,7 +48,6 @@ void push() {
4948 linkedStack .push (17 );
5049
5150 Assertions .assertEquals (17 , linkedStack .peek ());
52-
5351 }
5452
5553 @ Test
You can’t perform that action at this time.
0 commit comments