ArrayUtility
classIn the file ArrayUtility.java
write a the class ArrayUtility
that includes a series of static methods that will be useful in developing sorting algorithms.
The randomIntArray()
method creates an array filled with random integers. It takes two parameters: an int
describing the total length of the array, and an int
describing the upper (exclusive) bound of non-negative integer values that will be used to fill the array. The resulting int[]
array is returned.
Example: the call randomIntArray(10, 3)
would return a ten-element array of values randomly chosen from 0, 1, and 2, eg. [2,1,1,0,2,1,0,2,2,2]
.
Another common task in sorting is swapping the contents of two variables. Write a static void
method swap()
that takes three parameters--an int[]
array and two indices in that array--and exchanges the values at those two locations.