(String[] args)
| 34 | } |
| 35 | } |
| 36 | public static void main(String[] args) { |
| 37 | Counter petCount = new Counter(); |
| 38 | new PetCreator().stream() |
| 39 | .limit(20) |
| 40 | .peek(petCount::count) |
| 41 | .forEach(p -> System.out.print( |
| 42 | p.getClass().getSimpleName() + " ")); |
| 43 | System.out.println("\n" + petCount); |
| 44 | } |
| 45 | } |
| 46 | /* Output: |
| 47 | Rat Manx Cymric Mutt Pug Cymric Pug Manx Cymric Rat |