Josh Josh - 6 months ago 33
Java Question

java.lang.Void vs void vs Null

what exactly is the difference between

and can i just use

I'm asking this because I'm looking at sample android code where they used Void but eclipse is breaking on it (it says
Void cannot be resolved to a variable

mycode that breaks is

public class MyAsyncTask extends AsyncTask<Void, Void, Boolean>{

i use it like this

MyAsyncTask myAsyncTask = new MyAsyncTask();`
myAsyncTask.execute((Void),null);//this is the line that breaks "Void cannot be resolved to a variable"


You have an extra comma in your code.

                        //^extra comma right here

Also, there is no need to cast null to Void, because (1) Void has no instances and thus there is no Void object, and (2) casting null to anything is rather useless because null is a valid value for any Object data type.

Code should probably just be: