 
 
 
 
 
   
To insert a new element as the first one of a list: -

Note that we do not need to actually access the elements of the list to perform this operation.
Implementation:
public static ListNode insertFirst(ListNode lis, String s) {
  ListNode p = new ListNode();     // 1
  p.info = s;                      // 2
  p.next = lis;                    // 3
  lis = p;                         // 4
  return lis;
}
 
 
 
 
