So I made these two pieces of code, so im trying to see if there is any difference but they seem to do the same thing, can somebody tell me what is the funcionality difference? I have to use wildcards otherwise I get an error, but I found this new way.
Instructor is a subclass of User
I saw most people using this one
public class Utils {
public static void printUser(GenericList<? extends User> user){
//
}
}
public class Main {
public static void main(String[] args) {
var users = new GenericList<Instructor>();
Utils.printUser(users);
}
}
And I made this one
public class Utils {
public static <T extends User>void printUser(GenericList<T> user){
//
}
public class Main {
public static void main(String[] args) {
var users = new GenericList<Instructor>();
Utils.printUser(users);
}
}