Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 com.mycompany.app21;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- *
- * @author Admin
- */
- public class Main5 {
- public static void main(String[] args) {
- //
- List<Person> list = new ArrayList<>();
- list.add(new Person("name1", 11));
- // вывод элементов стим - объектов типа Person
- list.stream().filter(p -> p.getName()!=null)
- .filter(p -> p.getAge()>10 && p.getAge()<20)
- .forEach(System.out::println);
- //
- List<Person> dst = list.stream().filter(p -> p.getName()!=null)
- .filter(p -> p.getAge()>10 && p.getAge()<20).collect(Collectors.toList());
- //
- System.out.println("dst.list=" + dst.size());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement