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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started