Question: How do I add two 1D arrays into a 2D array In the code below you can see I'm adding one of the array into

How do I add two 1D arrays into a 2D array

In the code below you can see I'm adding one of the array into the 2D array but I want to add both of them

int numOfSpeed = 5;

int numOfAngels = 8;

int [] speedsArray = {10, 20, 30, 40, 50 };

int [] angelsArray = {10, 20, 30, 40, 50, 60, 70, 80 };

int [][] speedAngels = new int [numOfSpeed][numOfAngels];

int results = 0;

for(int row = 0; row < numOfSpeed; row++ ){

for(int col =0; col < numOfAngels; col++ ){

speedAngels[row][col]= speedsArray[results];

results++;

System.out.println(speedAngels[row][col] + " ");

}

}

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!