public void addElement(int data) { // add a new integer at head of list head = new ListCell(data, head); if(tail==null){ tail=head; } else if(tail.next!=null){ tail = tail.next; } }