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;
- /**
- *
- * @author Admin
- */
- public class Main3 {
- public static void main(String[] args) {
- MyFilter filter1 = new MyFilter(2);
- MyFilter filter2 = new MyFilter(3);
- ArrayList<String> list = new ArrayList<>();
- list.add("ONE");
- list.add("TWO");
- list.add("TWO123");
- list.add("O");
- //
- System.out.println("\nSAMPLE1:");
- // filter1 - объект реализует интерфейс Predicate
- list.stream().filter(filter1).forEach(x -> System.out.println(x));
- System.out.println("\nSAMPLE2:");
- // filter1, filter2 - объект реализует интерфейс Predicate
- list.stream().filter(filter1)
- .filter(filter2).forEach(x -> System.out.println(x));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement