Is sure to cast ? super T
to T
?
Example:
public void method(? super Date param)
{
Date d = (Date)param;
}
I'm not able to do Date d = param
. Why?
Is sure to cast ? super T
to T
?
Example:
public void method(? super Date param)
{
Date d = (Date)param;
}
I'm not able to do Date d = param
. Why?
You need to follow a tutorial on generics ;)
Here's what it should look like:
public <T extends Date> void method(T date){
Date d = date;
}
You specify the generic type before the parameter input. I suggest taking the time to read this: https://docs.oracle.com/javase/tutorial/java/generics/