1. If you want to use Java to represent a number: 100. Then you need to assign it to a variable and define the data type and name for it, similar to this:
Define variables
int number = 100;
2. You can also temporarily not initialize it, and then assign a value to the variable when certain combined calculations are needed:
Declare the variable without initializing the value
int sum; sum = 1+1; System.out.println(sum);
Local declaration If a variable is not assigned a value, it cannot be used directly.
The above is the detailed content of How to define variables in java. For more information, please follow other related articles on the PHP Chinese website!