In the Utils class provided to you in this exercise, please fill in the details for a method called swapArray(). You can either upload a file or use the Edit tab to submit your work. The VPL tester will pass an arbitrary array of type integer to your method, along with the value of the locations in the array of two values that need to be swapped (exchanged). For instance, in the illustration below, the method swapArray is told to swap the values in positions 0 and 2 of an array made up of {10, 20, 30, 40, 50}. The three input parameters to the method are the array, as well as the two array indices (i and j) that control which elements to swap.
In the Utils class provided to you in this exercise, please fill in the details for a method called swapArray(). You can either upload a file or use the Edit tab to submit your work. The VPL tester will pass an arbitrary array of type integer to your method, along with the value of the locations in the array of two values that need to be swapped (exchanged). For instance, in the illustration below, the method swapArray is told to swap the values in positions 0 and 2 of an array made up of {10, 20, 30, 40, 50}. The three input parameters to the method are the array, as well as the two array indices (i and j) that control which elements to swap.
Your task is to write the contents of the method that can execute this swap.
Step by step
Solved in 4 steps with 2 images