Write a method called surroundWith that takes an integer x and an integer y as parameters and
Question:
Write a method called surroundWith that takes an integer x and an integer y as parameters and surrounds all nodes in the list containing the value x with new nodes containing the value y. In particular, each node that contains the value x as data should have a new node just before it and just after it that each contain the value y. If no nodes in the list contain the value x, then the list should not be modified. For example, suppose that the variables list1, list2, and list3 store the following sequences of values:
and we make the following calls:
then the variables will now store these sequences:
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Question Posted: