Question: give me the answer for very low level public void swap (T elCurrent, T elSwap) Which will receive 2 parameters, the current element (elCurrent) and
give me the answer for very low level
public void swap(T elCurrent, T elSwap)
- Which will receive 2 parameters, the current element (elCurrent) and the swap element (elSwap) that will be switched with each other.
- If the current element (elCurrent) is not in the list, the method should ignore the swap, and return null.
- Example:
When the method is applied with elCurrent = 7, elSwap = 40 to the following list :
4 33 7 8 55 1 2
Output will be:
4 33 40 8 55 1 2
When the method is applied with elCurrent = 10, elSwap = 40 to the following list :
4 33 7 8 55 1 2
Output will be:
4 33 7 8 55 1 2 //No change (current element is NOT in the list)
- Hint: You can call printAll( ) then in order to check the correctness of the method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
