Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

code should be in java! Thank you! This method reverses the subsection of the pa

ID: 3709983 • Letter: C

Question

code should be in java!

Thank you!

This method reverses the subsection of the passed array defined by index1 and index2. index2 is non-inclusive and will not be swapped with index1. If *index1index2 then the two indexes will be swapped before they are checked for validity. eparam arr -the array to reverse eparam index1-the first index of the subsection eparam index2 -the non-inclusive upper bound of the subsection, " last element swapped wil1 be at the index Cindex2-1) ethrows IndexOutOfBoundsException if index1 or (index2-1) are not valid indexes of arc se public void reverseWindow(int[] arr, int start, int end) throws IndexOutOfBoundsException

Explanation / Answer

public class ReverseWindow { public void reverseWindow(int[] arr, int start, int end) throws IndexOutOfBoundsException { end--; if(start > end) { int temp = start; start = end; end = temp; } if(start < 0 || end < 0 || start >= arr.length || end >= arr.length) { throw new IndexOutOfBoundsException(); } int temp; while (start