Comma operator and Comma separator: Java

Comma separator (not seperator :P) is one that divides and differentiates. As a separator comma is partial and is used to differentiate between two method arguments, or to separate definitions.


subroutine(var A, var B); // comma used to divide

Comma operator has only one use in Java: in the control expression of a for loop when you want to have multiple statements expressed in control expression of for loop at once. Mind my limited knowledge of english and use the following example to have gist of what i want to say.

for(a=1,b=2; a < b; a++,b++){//i am immortal}

No comments:

Post a Comment