Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.List;
- public class FourthExercise {
- public static void main(String[] args) {
- List<Integer> list = Arrays.asList(11, -2, 42, -7, 56);
- int sumOfNumbers = list.stream()
- .mapToInt(it -> 2 * it * it - 5 * it + 6)
- .sum();
- System.out.println("Sum of numbers is: " + sumOfNumbers);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement