0

There are two different String arrays.

String a[] = {"a", "b", "c", "d"}; String b[] = {"1", "2", "3", "4"}; 

And I want to make these two arrays into a 4*2 matrix.

String answer[][] = {{"a", "1"}, {"b", "2"}, {"c", "3"}, {"d", "4"}}; 

How can I make this matrix?

String[][] result = {a,b}; 

After making this result, is there any other way to rotate the rows and columns of the result?

2
  • Hi! What have you tried so far? Commented Sep 23, 2021 at 9:55
  • "I want to make these two arrays into a 4*2 matrix." You've got the syntax, right there. Commented Sep 23, 2021 at 9:55

1 Answer 1

2
public static String[][] convert(String[] a, String[] b) { String[][] res = new String[a.length][]; for(int row = 0; row < a.length; row++) res[row] = new String[] { a[row], b[row] }; return res; } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.