X348: addNodeAfterRef7

Consider the following class definition:
   class Link{
      Object data;
      Link next;
Link p has a reference to the first node. Link ref is a reference to the node where you would add the integer param as the data for the added node. Make sure to account for edge cases! If p AND parameter are null, point p to integer param data. If the reference parameter is null then prepend the integer parameter to the list.

Initial Setup Final Configuration


addNodeAfterRef(Link.CreateList(1,2,3,4),Link.CreateList(2),9) -> Link.CreateList(1,2,9,3,4)

Practice a different Java exercise