Skip to content

Commit a08470d

Browse files
author
AmiyahJo
committed
feat: adds code in ListNode push method and boolean isEmpty
1 parent 59bfb07 commit a08470d

File tree

1 file changed

+4
-1
lines changed
  • lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12

1 file changed

+4
-1
lines changed

lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public Stack() {
1010

1111
public void push(int value) {
1212
// Your code here
13+
ListNode newNode = new ListNode(value);
14+
newNode.next = top;
15+
top = newNode;
1316
}
1417

1518
public int pop() {
@@ -21,6 +24,6 @@ public int peek() {
2124
}
2225

2326
public boolean isEmpty() {
24-
return true;
27+
return top == null;
2528
}
2629
}

0 commit comments

Comments
 (0)