Reputation: 14300
In an Android framework I am trying to understand, I find a statement like this:
public Call<GeneralResponseSO> performApiCall(/*...*/) {
// ...
}
But GeneralResponseSO
is defined like this:
public class GeneralResponseSO<T> {
// ...
}
Shouldn't the api method specify which type T
is? I can't seem to grasp why the compiler doesn't give an error, and what type T
then is.
Or does the compiler do magic to filter out all the generics from the class? So that all variables/methods that use T
are removed? I wouldn't expect the Java compiler to perform such magic though.
Upvotes: 0
Views: 525
Reputation: 18235
A generic class / interface without type parameter is Raw type
.
Raw type is unchecked during compile (and you may see warning in IDE such as Intellij) and may cause exception at runtime.
Note: Example.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
Upvotes: 2