Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<Shape> shapes = new ArrayList<Shape>(){};
- shapes.add(rect);
- shapes.add(circle);
- shapes.add(tri);
- shapes.add(piramyd);
- shapes.add(cuboid);
- shapes.add(sphere);
- List<Shape> orderdByVolume = shapes.stream()
- .filter(s -> s instanceof VolumeMeasurable)
- .filter(v -> ((VolumeMeasurable) v).getVolume() > 40)
- .collect(Collectors.toList());
- for (Shape shape : orderdByVolume) {
- System.out.println(shape);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement