filmov
tv
Find summation of two array in java | build logical thinking | Coding in sinhala #java #programming

Показать описание
This code performs element-wise summation of two integer arrays and prints the resulting array to the console.
sumArray(int[] array1, int[] array2): This method takes two integer arrays, array1 and array2, of the same length and returns a new array where each element is the sum of the corresponding elements from array1 and array2. It iterates through the arrays, calculates the sum element-wise, and stores the results in a new array.
main(String[] args): This is the main method of the program. It creates two integer arrays, array1 and array2, with predefined values. Then, it calls the sumArray method to calculate the sum of these arrays element-wise and stores the result in a new array called newArray. Finally, it prints the elements of newArray to the console.
sumArray(int[] array1, int[] array2): This method takes two integer arrays, array1 and array2, of the same length and returns a new array where each element is the sum of the corresponding elements from array1 and array2. It iterates through the arrays, calculates the sum element-wise, and stores the results in a new array.
main(String[] args): This is the main method of the program. It creates two integer arrays, array1 and array2, with predefined values. Then, it calls the sumArray method to calculate the sum of these arrays element-wise and stores the result in a new array called newArray. Finally, it prints the elements of newArray to the console.