Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void insertAtBack(Object data)// add Object at first position
- {
- if(isEmpty()){
- head.next = new Node(data); // second method : head = new Node(data);
- tail = head.next; // second method : tail = new Node(data);
- }
- else{
- current = head;
- while(current.getNext()!=null){
- current = current.getNext();
- }
- current.setNext(new Node(data));
- }
- length++;
- }// end insertAtFront
Advertisement
Add Comment
Please, Sign In to add comment