| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff 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 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments