Update StackOfLinkedList.java
This commit is contained in:
parent
d60f836861
commit
2ea534000b
@ -1,7 +1,5 @@
|
||||
/**
|
||||
*
|
||||
* @author Varun Upadhyay (https://github.com/varunu28)
|
||||
*
|
||||
*/
|
||||
|
||||
// An implementation of a Stack using a Linked List
|
||||
@ -42,7 +40,7 @@ class Node {
|
||||
|
||||
/**
|
||||
* A class which implements a stack using a linked list
|
||||
*
|
||||
* <p>
|
||||
* Contains all the stack methods : push, pop, printStack, isEmpty
|
||||
**/
|
||||
|
||||
@ -54,8 +52,7 @@ class LinkedListStack {
|
||||
Node n = new Node(x);
|
||||
if (head == null) {
|
||||
head = n;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Node temp = head;
|
||||
n.next = temp;
|
||||
head = n;
|
||||
@ -85,8 +82,7 @@ class LinkedListStack {
|
||||
while (temp != null) {
|
||||
if (temp.next == null) {
|
||||
System.out.print(temp.data);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.out.print(temp.data + " -> ");
|
||||
}
|
||||
temp = temp.next;
|
||||
|
Loading…
Reference in New Issue
Block a user