(String[] args)
| 7 | |
| 8 | public class PetCounter4 { |
| 9 | public static void main(String[] args) { |
| 10 | TypeCounter counter = new TypeCounter(Pet.class); |
| 11 | new PetCreator().stream() |
| 12 | .limit(20) |
| 13 | .peek(counter::count) |
| 14 | .forEach(p -> System.out.print( |
| 15 | p.getClass().getSimpleName() + " ")); |
| 16 | System.out.println("\n" + counter); |
| 17 | } |
| 18 | } |
| 19 | /* Output: |
| 20 | Rat Manx Cymric Mutt Pug Cymric Pug Manx Cymric Rat |