Write a program in java to accept 8 numbers and 12 numbers in two separate Single Dimension Array then merge all these elements in first array to new array. please solve these program,......... don't spam.......
Answers
Answered by
0
Answer:
import java.util.Arrays;
public class Main
{
public static void main(String[] args) {
java.util.Scanner s = new java.util.Scanner(System.in);
int[] arr1 = new int[12];
int[] arr2 = new int[8];
for(int i = 0; i < arr1.length; i++)
{
System.out.print("Enter number " + (i+1) + " in aray 1:");
int x = s.nextInt();
arr1[i] = x;
}
for(int i = 0; i < arr2.length; i++)
{
System.out.print("Enter number " + (i+1) + "in aray 2:");
int y = s.nextInt();
arr2[i] = y;
}
System.out.println("Combined array is "+ Arrays.toString(arr1) + Arrays.toString(arr2));
}
}
Explanation:
Similar questions
Math,
3 months ago
Science,
3 months ago
Math,
3 months ago
Geography,
7 months ago
Business Studies,
7 months ago
Social Sciences,
11 months ago