X356: removeRefNext9

Consider the following class definition:
   class Link{
      Object data;
      Link next;
   }
Link p has a reference to the first node, of list L. Integer val is the value of a node in L. You would remove the next node (after the node containing val) if there was one. Make sure to account for edge cases! If the value exists multiple times, assume the value is of the first instance. If the int parameter is null or doesn't exist then don't change the list.

Initial Setup Final Configuration

Examples:

removeRefNext(Link.CreateList(1,2,3,4),2) -> Link.CreateList(1,2,4)
Reset
Visualize

Practice a different Java exercise