Question: Write a method named unflatten that accepts three parameters: a 1 - D array of integers, and a number of rows and columns. Your method
Write a method named unflatten that accepts three parameters: a D array of integers, and a number of rows and columns. Your method should convert the D array into a D array with the given number of rows and columns, where values are transferred in rowmajor order into the twodimensional array. For example, if the given array is declared:
int a ;
Then the call of unflattena should return the following D array:
The call of unflattena should return the following D array:
If the array's contents do not fit exactly into a D array of the given dimensions, your method should throw an IllegalArgumentException. Your code should work for an array of any size. Your method should not modify the array that is passed in
Submit
Method: Write a Java method as described, not a complete program or class.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
