Java: bounded wildcards or bounded type parameter?
It depends on what you need to do. You need to use the bounded type parameter if you wanted to do something like this: public <T extends Shape> void addIfPretty(List<T> shapes, T shape) { if (shape.isPretty()) { shapes.add(shape); } } Here we have a List<T> shapes and a T shape, therefore we can safely shapes.add(shape). … Read more