This is my code and after printing the result i get is 0 for each item
import java.util.Scanner; class Node { public int data; public Node next; //Link constructor public Node(int d1) { this.data=data; } //Print Link data public void printNode() { System.out.print(data); } } class LinkList { private Node first; //LinkList constructor public LinkList() { first=null; } //Returns true if list is empty public boolean isEmpty() { return first == null; } //Inserts a new Link at the first of the list public void insert(int d1) { Node newNode = new Node(d1); newNode.next = first; first = newNode; } //Deletes the link at the first of the list public Node delete() { Node temp = first; first = first.next; return temp; } //Prints list data public void printList() { Node current = first; System.out.print("List: "); while(current != null) { current.printNode(); current = current.next; } System.out.println(""); } } class LinkListTest { public static void main(String[] args) { Scanner scan = new Scanner(System.in); LinkList list = new LinkList(); int data=0; System.out.print("Please enter a succession of integers. Enter 0 to end "); while(data!=999){ data=scan.nextInt(); list.insert(data); } list.printList(); while(!list.isEmpty()) { Node deletedLink = list.delete(); System.out.print("deleted: "); deletedLink.printNode(); System.out.println(""); } list.printList(); } }