ublic class MyLinkedList { public class Node { int data ; Node nextNode ; public Npode(int inVal) { data = inVal ; nextNode = null ; } } Node head ; public MyLinkedList() { head = null ; } public boolean isEmpty() { if (head == null) return(true) ; else return (false) ; } public void add(int newVal) { Node aNode = new Node(newVal) ; Node wb, wf ; // insert into empty list if (isEmpty() ) { head = aNode ; return; } wb = null ; wf = head ; // handle insert at head of list if (wf.data > newVal) { aNode.nextNode = wf ; head = aNode ; return ; } // handle insert middle and end while ( (wf != null) && (wf.data < newVal) ) { wb = wf ; wf = wf.nextNode ; } aNode.nextNode = wf ; wb.nextNode = aNode ; return ; } public void printAll() { Node tempNode ; tempNode = head ; while (tempNode != null) { System.out.println(tempNode.data) ; tempNode = tempNode.nextNode ; } } public static void main(String args[]) { MyLinkedList ll = new MyLinkedList() ; ll.add(2) ; // insert into empty ll.add(5) ; // insert end ll.add(9) ; // insert end ll.add(3) ; // insert middle ll.add(1) ; // insert front ll.printAll() ; } }