How to define variables in Java?
In Java, variables can be defined using keywords such as int, double, boolean, char, etc. The syntax is:
<数据类型> <变量名> = <初始值>;
Where represents the type of the variable,
For example, define an integer variable called num with an initial value of 10.
int num = 10;
Create a string variable called ‘name’ with an initial value of “John”.
String name = "John";
Note that if you do not assign an initial value to a variable, you will need to use the keyword “null” to indicate that the variable’s initial value is null. For example, defining an empty reference variable, person:
Person person = null;