FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Create PredicateEx3.java · janbodnar/Java-Advanced@8aff8af · GitHub

Commit 8aff8af

Browse files
authored
Create PredicateEx3.java
1 parent 3d7ef22 commit 8aff8af

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎functional/PredicateEx3.java‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.zetcode;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.function.Predicate;
6+
7+
public class PredicateEx3 {
8+
9+
public static void main(String[] args) {
10+
11+
List<Country> countries = new ArrayList<>();
12+
13+
countries.add(new Country("Iran", 80840713));
14+
countries.add(new Country("Hungary", 9845000));
15+
countries.add(new Country("Poland", 38485000));
16+
countries.add(new Country("India", 1342512000));
17+
countries.add(new Country("Latvia", 1978000));
18+
countries.add(new Country("Vietnam", 95261000));
19+
countries.add(new Country("Sweden", 9967000));
20+
countries.add(new Country("Iceland", 337600));
21+
countries.add(new Country("Israel", 8622000));
22+
23+
Predicate<Country> p1 = c -> c.getName().startsWith("I") &&
24+
c.getPopulation() > 10000000;
25+
26+
countries.stream().filter(p1).forEach(System.out::println);
27+
}
28+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL