abouttr3

Untitled

Oct 6th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. public void insertAtBack(Object data)// add Object at first position
  2.     {
  3.         if(isEmpty()){          
  4.             head.next = new Node(data); // second method : head = new Node(data);
  5.             tail = head.next; // second method : tail = new Node(data);
  6.         }
  7.         else{
  8.             current = head;
  9.        
  10.             while(current.getNext()!=null){
  11.                 current = current.getNext();
  12.             }
  13.             current.setNext(new Node(data));
  14.         }
  15.         length++;
  16.     }// end insertAtFront
Advertisement
Add Comment
Please, Sign In to add comment