Prev Next

Java / Programs

Write a simple Java program to find the sum of all integers in a List.

public class SumofIntegersOfList {

	public static void main(String[] args) {
		List<Integer> myList = Arrays.asList(1, 2, 3, 4, 5);

		System.out.println("Sum :" + myList.stream().reduce((i, j) -> i + j));

	}
}

More Related questions...

Show more question and Answers...

JVM

Comments & Discussions