Create and test an utility class ArrayUtility containing various utility methods for arrays. 11. Construct a package
Fantastic news! We've Found the answer you've been seeking!
Question:
Create and test an utility class ArrayUtility containing various utility methods for arrays.
- 11. Construct a package "util" (under src folder), if not already created. Construct a sub-package "array" under the package sort. In this sub-package (select), Construct a public class named ArrayUtility and a public class named ArrayUtilityTest.
- 12a. In ArrayUtility class, Construct a public static method toString that receives an array of int's, a start string, a separator string and an end string. It returns a String starting with the start string, followed by the array elements separated by the separator and ending with the end string.
- 12b. In ArrayUtilityTest class, Construct a public static method toStringTest that prints the results for the following 5 lengths of arrays, using different types of brackets and separators for each: empty, singleton, two elements, 5 elements and 20 elements. Call only this class in the main method and check the results.
- 13a. In ArrayUtility class, Construct a public static method equals that receives two arrays of int's and returns true if they have the same length and equal corresponding elements.
- 13b. In ArrayUtilityTest class, Construct a public static method equalsTest that prints the results for the following 6 cases: two empty arrays, one empty and one singleton, two singleton with the same element, two singleton with different elements, two arrays with two identical elements, two arrays with two different elements. Call only this class in the main method and check the results.
- 14. In ArrayUtility and ArrayUtilityTest, design, implement and test a method named isSorted that checks if an array of int-s is already sorted, i.e. all the elements are in increasing order.
- 15. In ArrayUtility and ArrayUtilityTest, design, implement and test a method named generateIntArray that generates a random array with the provided length having elements randomly generated between a minimum and maximum value, including those values.
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date: