Guest User

Untitled

a guest
May 27th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. public void add(int i, Object obj)
  2.   {
  3.          if(i < 0 || i >= nodeCount)
  4.                 throw new IndexOutOfBoundsException();
  5.                
  6.      
  7.         ListNode node = head, prev = null;
  8.        
  9.    
  10.        for(int j = 0; j < i; j++)
  11.             node = node.getNext();
  12.        
  13.        prev = node;
  14.        node = node.getNext();
  15.        ListNode add = new ListNode(obj,node);
  16.        prev.setNext(add);
  17.        
  18.            
  19.   }
Add Comment
Please, Sign In to add comment