Question
You are given 2 different arrays of the same size that are filled with numbers. Write a method that merges these two arrays together. Every
You are given 2 different arrays of the same size that are filled with numbers. Write a method that merges these two arrays together. Every item from the first array should be in the even indices of your new array and every item from the second array should be in the odd indices. The order of each array should be preserved. Here is some sample code to get you started:
public class Problem07{
public static void main(String[] args) {
int[] firstArray = {1,3,5,7,9};
int[] secondArray = {2,4,6,8,10};
int[] result = mergeArrays(firstArray, secondArray);
for (int i = 0; i < result.length; i++) {
System.out.println(result[i]);
}
}
public static int[] mergeArrays(int[] firstArray, int[] secondArray){
// Your code here
}
}
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