Lets say we have the following worker:
SW<Void, Void>(){
Void doInB(){
....
...
return null;
}
My question: why does SwingWorker force us to return nulls if the doInB() method does not return anything. When we write our own functions in Java we can have void without return statements.
Why was SwingWorker designed in this fashion?
SwingWorker question
Page 1 of 13 Replies - 116 Views - Last Post: 18 July 2012 - 03:05 PM
Replies To: SwingWorker question
#2
Re: SwingWorker question
Posted 17 July 2012 - 06:30 PM
Because SwingWorker specifies return types via generics and 'void' isn't a valid generic keyword.
#3
Re: SwingWorker question
Posted 17 July 2012 - 06:41 PM
There is actually a Void class to represent a void return type for this purpose.
http://docs.oracle.c.../lang/Void.html
It's not SwingWorker specifically. It goes with the territory of generics, and how methods work.
http://docs.oracle.c.../lang/Void.html
Quote
Why was SwingWorker designed in this fashion?
It's not SwingWorker specifically. It goes with the territory of generics, and how methods work.
#4
Re: SwingWorker question
Posted 18 July 2012 - 03:05 PM
macosxnerd101, on 17 July 2012 - 09:41 PM, said:
There is actually a Void class to represent a void return type for this purpose.
http://docs.oracle.c.../lang/Void.html
http://docs.oracle.c.../lang/Void.html
Cute, I had to write my own once, never thought the API might contained one
This post has been edited by pbl: 18 July 2012 - 03:44 PM
Reason for edit:: quote tags
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|