Java function that accept a type param and return a value of this type so don't have to cast the return type
For Known String type in and out:
public String stringReturnFunc(String out)
{
return out;
}
The compiler doesn't know anything about the type
For Known String type in and out:
public String stringReturnFunc(String out)
{
return out;
}
The compiler doesn't know anything about the type
public <T> T genricMT(T type)
{
return type;
}
If return type is of certain class-
CertainClass
public <T extends CertainClass> T genricMT(T type){
// now you can use YourType methods
return type;
}
No comments:
Post a Comment