Write a Java program to create a new array of length 2 from two arrays of integers with three elements and the new array will contain the first and last elements from the two arrays
- برمجة
- برمجة جافا
- 2021-05-01
- razanmazen8711884270
الأجوبة
import java.util.Arrays;
public class Exercise77 {
public static void main(String[] args)
{
int[] array1 = {50, -20, 0};
int[] array2 = {5, -50, 10};
System.out.println("Array1: "+Arrays.toString(array1));
System.out.println("Array2: "+Arrays.toString(array2));
int[] array_new = {array1[0], array2[2]};
System.out.println("New Array: "+Arrays.toString(array_new));
}
}
Sample Output:
Array1: [50, -20, 0] Array2: [5, -50, 10] New Array: [50, 10]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال