I'm doing some tests to understand in practice how the class works SwingWorker
in% of%, and I noticed that the swing
method requires doInBackground
return, even starting the variable of the form below:
SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
return null;
}
};
When declaring null
, the first parameter refers exactly to the return of the method mentioned, but even being SwingWorker<Void, Void>
, it forces Void
to return (if it does not inform the null return, the IDE has a semantic error and does not compile the code). Watch running on IDEONE .
If the signature is null
, why does it require return anyway? Is there a difference between protected Void doInBackground()
and Void
that would justify this behavior?