When a declaring a variable in Java we must first define the type of data the variable is going to hold. This could be a primitive or reference data type. Then a space will separate the data type from the variable name. When naming variables always begin your variable name with a lowercase letter. Although you could technically create names that start with a dollar sign '$' or underscore '_' it is strongly advised that you start with a lowercase letter. After the first lowercase letter, subsequent characters of the variable name may be uppercase, lowercase, numeric, dollar sign, or underscore.
You cannot use spaces in your variable names!
Naming Conventions
Variable naming conventions are to always start with a lowercase letter. If your variable is the result of multiple words then there should be no spaces between words and the first letter of each subsequent word should be capitalized. This practice is called camel-case.
Ex: int intialCount, maxNumber, triangularNumber;
double interestRate;
String companyName;
boolean doYouWantToBuildSnowman;
Scanner userInput;
The above examples have the data types colored red and the variable names colored blue. Notice in the first line that when declaring variables of the same data type they are separated by commas. Additionally, every statement must end with a semicolon.
Ex: String firstName = "";
String is the data type, firstName is the variable name a.k.a. the identifier, the variable has been initialized to equal an empty string, and the semi-colon ends the statement. Initializing a variable simply means that you have given it a starting value.
Other Examples
int num1, num2;
double interest$Rate;
boolean Certificate_Of_Occupancy;
String name1, name2, zip_Code;
float piNum = 3.141592F; //Notice the 'F' placed at the end of the float value.
long numStars = 100000000000L; // Notice the 'L' placed at the end of the long value.
double co2 = 407.05 // double values can also be written using exponent notation.