Advertisement
EBobkunov

lambda function

Mar 11th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | Source Code | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Random;
  3.  
  4. public class Main {
  5.         public static void main(String[] args) {
  6.             ArrayList<Integer> myaw = new ArrayList<>();
  7.             Random random = new Random();
  8.             for (int i = 0; i < 10; i++) {
  9.                 myaw.add(random.nextInt(200)-100);
  10.             }
  11.             myaw.stream()
  12.                     .filter(x -> x % 3 == 0)
  13.                     .map(Math::abs)
  14.                     .forEach(System.out::println);
  15.         }
  16. }
Tags: LaMDA
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement