The most common scenario for creating variables is one that has all of the required information available when the declaration is made. For instance, if we knew a player's age, storing it would be as easy as doing the following:
int currentAge = 32;
Here, all of the basic requirements have been met:
- A data type is specified, which is int (short for integer).
- A unique name is used, which is currentAge.
- 32 is an integer, which matches the specified data type.
- The statement ends with a semicolon.
However, there will be scenarios where you'll want to declare a variable without knowing its value right away. We'll talk about this topic in the following section.