/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package std; import java.util.ArrayList; /** * * @author (C)Y.D.Zakovryashin, 05.12.2022 */ public class DemoLambda { public static void main(String[] args) { DemoLambda demo = new DemoLambda(); ArrayList al = demo.init(); demo.print(al); al.removeIf((Integer x) -> x % 2 != 0); demo.print(al); al.forEach((Integer x) -> { System.out.print(x * 2 + ", "); }); System.out.println(""); } private ArrayList init() { int[] ai = {1, 2, 3, 4, 5, 6, 77, 78}; ArrayList al = new ArrayList<>(); for (int i : ai) { al.add(i); } return al; } private void a(int x) { // new ? implements DemoFunInterface { ... } DemoFunInterface d = x1 -> { return String.valueOf(x1); }; } private void print(ArrayList al) { for (Integer i : al) { System.out.print(i + ", "); } System.out.println(); } }