JavaDeclare Multiple Variables
Declare Many Variables
To declare more than one variable of thesame type, you can use a comma-separated list:
Example
Instead of writing:
int x = 5;int y = 6;int z = 50;System.out.println(x + y + z); // 61You can write:
int x = 5, y = 6, z = 50;System.out.println(x + y + z); // 61Note: Declaring many variables in one line is shorter, but writing one variable per line can sometimes make the code easier to read.
One Value to Multiple Variables
You can also assign thesame value to multiple variables in one line:

