I am reading a Java text book and the writer to show usefulness of generic types in methods use an example:
public class BoundedTypeDemo {
public static void main(String[] args ) {
Rectangle rectangle = new Rectangle(2, 2);
Circle circle = new Circle(2);
System.out.println("Same area? " +
equalArea(rectangle, circle));
}
public static <E extends GeometricObject> boolean equalArea(E object1, E object2) {
return object1.getArea() == object2.getArea();
}
}
This is a ridiculous example... I do not understand where is the usefulness of using generic type in this particular example cause we could use GeometricObject as the type of equalArea method's parameters