Java Term of the Week: Variable
Seeing as I had a look at declaring variables this week, it seems a good idea to re-enforce what they are. A variable is a container that holds values that are used in a Java program. When I first started programming I always thought of them as a bucket to put something in. For example, if I wanted to hold the approximate population of the Earth I could create a variable:
long populationOfEarth = 6700000000L;
The variable "populationOfEarth" is declared to be a long data type and initialized to a value of 6.7 billion. Note the use of the "L" at the end of the statement. A whole number literal is treated as an int value unless you specifically tell the compiler that it's a long.


Comments
No comments yet. Leave a Comment