Consider the class hierarchy
public class A {
public void say() {
System.out.println("I am A");
}
}
and
public class B extends A {
public void say() {
System.out.println("I am B");
}
}
In a third class I have two different methods
private static void print(A input) {
}
private static <T extends A> void print2(T input) {
}
What is the "difference" between them?
I can both call them with an instance of A and all subclasses of A:
public class Test {
private static void print(A input) {
input.say();
}
private static <T extends A> void print2(T input) {
}
public static void main(String[] args) {
B b = new B();
print(b);
print2(b);
}
}
Thank you for your help!
P.S.: The difference between
private static void print(java.util.List<A> input) {
}
private static <T extends A> void print2(java.util.List<T> input) {
}
is clear!