I have this Java code.
public T readObjectData(ByteBuffer buffer, Class type) {
...
T retVal = (T) summaries;
return retVal;
You are probably confused by a similar and more common declaration:
class MyClass {
private T myMethod(T a){
return a;
}
}
In above case, there is no need for " after private ( private )
because the T it's using is the same than the one defined in the class MyClass
Even more, if you write
class MyClass {
private T myMethod(T a){
return a;
}
}
then the meaning is that the myMethod return type is (potentially) different than the MyClass type. As if you wrote this instead:
class MyClass {
private T2 myMethod(T2 a){
return a;
}
}
Credits: Took the example from "Kanagavelu Sugumar"'s longer answer to How to use Class