# Answer to Question #59017 in Java | JSP | JSF for Sherlynn

Question #59017

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

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

Expert's answer

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);

}

}

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);

}

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

Assignment Expert11.04.16, 17:00Dear 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.

Sherlynn10.04.16, 05:08hi need the answers quick due to exam

## Leave a comment