June 2018
Beginner
722 pages
18h 47m
English
The comma , is used for the separation of method parameters, listed in parentheses:
void someMethod(int i, String s, int j) { //... String s = anotherMethod(5, 6.1, "another param"); //...}
A comma can also be used to separate variables of the same type in the declaration statement:
int i, j = 2; k;
In the preceding example, all three variables, i, j, and k, are declared to be of the int type, but only variable j is initialized to 2.
The use of a comma in a looping statement serves the same purpose of the declaration of multiple variables (see Chapter 10, Control Flow Statements):
for (int i = 0; i < 10; i++){ //...}
Read now
Unlock full access