What it actually comes down to. Declaring a variable means that you create a variable object.
STEP:
- add a type to the variable
in this case we want to add up integers, so the type int will be our choice:
At this point:
we have declared variable a and b.
=> NEXT STEP IS TO INITIALISE THE VARIABLES
EXTRA INFORMATIONN..
So, now we got 2 objects of type int. These variables got no value, so if you want to print the value it gives you an error:
Checking the code, eclipse gives you indeed an error message. You can check what is wrong if you click the error sign on the left (1). This will show the error (2).
So, eclipse rightly states that the variable has no value yet.
(and you can’t print something that has no value, right?)
Therefore we have to give the variable a value
in java-terms this is called: initialising the variable.