lr12 -> e2-6

This commit is contained in:
2026-04-11 18:58:43 +05:00
parent 661d20744a
commit 7310b240fd
5 changed files with 105 additions and 0 deletions

20
lr12/e6.java Normal file
View File

@@ -0,0 +1,20 @@
package lr12;
import java.util.Arrays;
public class e6 {
public static long sum(int[] arr) {
if (arr == null || arr.length == 0) {
return 0;
}
return Arrays.stream(arr)
.parallel()
.sum();
}
public static void main(String[] args) {
int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 128, 512 };
System.out.println("Sum = " + sum(array));
}
}