public void displayList() { SLink current = first; if (isEmpty()) { System.out.println("list is empty."); return; } while (current.next != null) { current.displayLink(); System.out.println(""); current = current.next; } }
public void insertFirst(int data) { SLink slink = new SLink(data); if (isEmpty()) first = slink; slink.next = first; first = slink; }