Question: Hi, Need help write a java class, incorporating the static methods below using 2D arrays, 3D arrays, and the System.arraycopy method . 1. public static

Hi,

Need help write a java class, incorporating the static methods below using 2D arrays, 3D arrays, and the System.arraycopy method .Hi, Need help write a java class, incorporating the static methods below

using 2D arrays, 3D arrays, and the System.arraycopy method . 1. public

static int numElements(int[J[] twoDim) a. if twoDim is null then return -1

b. otherwise, return the number of integers stored in twoDim. c. twoDim

may contain null rows d. if all rows of twoDim are null

1. public static int numElements(int[J[] twoDim) a. if twoDim is null then return -1 b. otherwise, return the number of integers stored in twoDim. c. twoDim may contain null rows d. if all rows of twoDim are null then return 0. e. do not use a nested loop to compute the number of elements; instead, use the length property of each non-null row Example: twoDim null, (9, 0, 8), null, 50, 7, 6, 3, 4)W The method returns 8 since there are eight integers in the array. 2. public static int numElements(int[]i threeDim) a. if threeDim is null then return -1 b. otherwise, return the number of integers stored in threeDim. c. threeDim may contain two-dimensional arrays that are set to null. d. if every two-dimensional array stored in threeDim is null then return 0. e. do not use a nested loop to compute the number of elements; instead, call the numElements method described in part 1. Example: threeDim null, 9, 0, 8), null, 10, 7, 6, 3, 4), (K9, 1, 50},99,11, 6)), null, f8, 9, 45, 8, 0), (6, 7, 2), {4, 8)) The method returns 24 since there are 24 integers in the array. public static int[] twoDimensionalToOneDimensional(int[][] arr) if arr is null then return null 3. otherwise (i) copy the non-null rows of arr to a one-dimensional array and (ii) return the one-dimensional array. arr can contain null rows . the length of the returned array should be equal to the number of integers stored in the non-null rows of arr; hint: use the result from method 1 to find the length of this array. copy the non-null rows in ascending order. In other words, first copy row 0 to the one-dimensional array, then row 1, 2, etc. if all the rows contained in arr are null then return an array whose length is zero. use the System.arraycopy method to copy the non-null rows of arr to the one-dimensional array . Example: Assume arr 11, 20, 50), {5, 8), null, 122, 100, 200, 1); The method returns the following one-dimensional array: 11, 20, 50, 5, 8, 22, 100, 200, 1) 4. public static int[] threeDimensionalToOneDimensional(int[]]] arr) if arr is null then return null otherwise (i) copy the non-null two-dimensional arrays in arr to a one- dimensional array and (ii) return the one-dimensional array. . arr may contain two-dimensional arrays that are set to null. the length of the returned array should be equal to the number of integers stored in the non-null two-dimensional arrays. copy the non-null two-dimensional arrays in ascending order. In other words, first copy array 0 to the one-dimensional array, then array 1, 2, etc. if all two-dimensional arrays contained in arr are null then return an array whose length is zero. for every non-null array stored in arr, use the System.arraycopy method to copy the result from twoDimensionalToOneDimensional into the one- dimensional array . . Example: Assume arr-{ {null, {9, 0, 8}, null, {0, 7, 6, 3, 4)}, {19, 1, 50), {99, 11), (6^, null f8, 9, 45, 8, 0), {6, 7, 2},

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!