Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
public class SumProd
|
||||
{
|
||||
public static void main(final String[] args)
|
||||
{
|
||||
int sum = 0;
|
||||
int prod = 1;
|
||||
int[] arg = {1,2,3,4,5};
|
||||
for (int i : arg)
|
||||
{
|
||||
sum += i;
|
||||
prod *= i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import java.util.Arrays;
|
||||
|
||||
public class SumProd
|
||||
{
|
||||
public static void main(final String[] args)
|
||||
{
|
||||
int[] arg = {1,2,3,4,5};
|
||||
System.out.printf("sum = %d\n", Arrays.stream(arg).sum());
|
||||
System.out.printf("sum = %d\n", Arrays.stream(arg).reduce(0, (a, b) -> a + b));
|
||||
System.out.printf("product = %d\n", Arrays.stream(arg).reduce(1, (a, b) -> a * b));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue