public interface LList { public void insertFirst (int item); public Node deleteFirst (); public int size(); public boolean empty (); public void traverse (); } class Node { private int data; private Node next; public Node () { this(0, null); } public Node (int d) { data = d; } public Node (int d, Node n) { data = d; next = n; } public void setData (int newData) { data = newData; } public void setNext (Node newNext) { next = newNext; } public int getData () { return data; } public Node getNext () { return next; } public void displayNode () { System.out.print (data); } } class LinkListADT implements LList { private Node first; public LinkListADT () { first = null; } public boolean empty () { return (first == null); } public int size () { int count = 0; Node current = first; while (current != null) { count++; current = current.getNext(); } return count; } public void insertFirst (int newData) { Node newFirst = new Node (newData); newFirst.setNext(first); first = newFirst; } public Node deleteFirst () { Node temp = first; first = first.getNext(); return temp; } public boolean search (int key) { boolean result = false; Node current = first; while (current != null) { if (current.getData () == key) { result = true; return result; } else current = current.getNext(); } return result; } public void traverse () { System.out.print ("Current list: "); Node current = first; while (current != null) { current.displayNode (); System.out.print (" "); current = current.getNext(); } System.out.println (); } } class Listex1 { public static void main (String[] args) { LinkListADT list1 = new LinkListADT (); for (int i = 1; i <= 10; i++) { list1.insertFirst(i); list1.traverse(); } System.out.println ("Number of nodes on the list: " + list1.size()); System.out.println ("Search for 6: " + list1.search(6)); System.out.println ("Search for 12: " + list1.search(12)); for (int i = 1; i <= 10; i++) { list1.deleteFirst(); list1.traverse(); } } }