шпаргалки
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

52 lines
1.2 KiB

/*
* 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<Integer> 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<Integer> init() {
int[] ai = {1, 2, 3, 4, 5, 6, 77, 78};
ArrayList<Integer> 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<Integer> al) {
for (Integer i : al) {
System.out.print(i + ", ");
}
System.out.println();
}
}