What is the correct way to return a Void type, when it isn\'t a primitive? Eg. I currently use null as below.
interface B{ E method();
There is no generic type which will tell the compiler that a method returns nothing.
I believe the convention is to use Object when inheriting as a type parameter
OR
Propagate the type parameter up and then let users of your class instantiate using Object and assigning the object to a variable typed using a type-wildcard ?:
interface B{ E method(); }
class A implements B{
public T method(){
// do something
return null;
}
}
A> a = new A