write a method to receive 2 parameter: 1D array of integer number, integer value (row)
method to create 2D whose number of rows is equal to row. the method will copy all values from 1D array into new array. the array will return the new array upon completion
1
Expert's answer
2016-04-11T10:18:04-0400
package javaapplication5; import java.util.*; public class JavaApplication5 { static int[][] Met(int[]arr,int row) { int[][] res = new int[row][arr.length]; for (int i = 0; i < row; i++) { for (int j = 0; j < arr.length; j++) { res[i][j] = arr[j]; } } for (int i = 0; i < row; i++) { for (int j = 0; j <res[i].length; j++) { System.out.print(res[i][j]); if(j==arr.length-1)System.out.println(); } } return res; } public static void main(String[] args) { int[]arr = new int[4]; for (int i = 0; i < 4; i++) { arr[i] = i; } int[][]mas = Met(arr,5); } }
Learn more about our help with Assignments: JavaJSPJSF
Comments
Assignment Expert
11.04.16, 17:00
Dear Sherlynn, Questions in this section are answered for free. We
can't fulfill them all and there is no guarantee of answering certain
question but we are doing our best. Although if you have serious
assignment that requires large amount of work and hence cannot be done
for free you can submit it as assignment and our experts will surely
assist you.
Sherlynn
10.04.16, 05:08
hi need the answers quick due to exam
Leave a comment
Thank you! Your comments have been successfully added. However, they need to be checked by the moderator before being published.
Comments
Dear Sherlynn, Questions in this section are answered for free. We can't fulfill them all and there is no guarantee of answering certain question but we are doing our best. Although if you have serious assignment that requires large amount of work and hence cannot be done for free you can submit it as assignment and our experts will surely assist you.
hi need the answers quick due to exam
Leave a comment