I will also write about variable declarations.
To use variables in Java programs First of all, we have to do something called "variable declaration".
In order to use a variable in a program, it must be named. The name of this variable is read as an identifier.
In addition, the type of variables is determined by the type of data to be handled. This type must be specified.
Click here for basic writing
Model name identifier;
Example: For age Specify the number type with int Specify the variable name (identifier) with age
int age;
For Java, use the symbol "=" (equal) as shown below Write the variable name represented by the identifier declared on the left side and the expression on the right side.
It does not matter whether there is a space between the variable and "=".
Variable name (identifier)=formula;
Example: Specify 30 It means assigning the value 30 to the variable age.
age = 30;
This means assigning the same value in the variable named age to the variable named sameAge.
sameAge = age;
You can also write declarations and assignments together.
Model name identifier=formula;
int age = 24;
Recommended Posts