This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Hi, The Java language specification makes no mention of a "comma operator;" Java doesn't have one like C does. But I do know what the question means. You can use a comma to separate variables in a single declaration, like
but that's not considered an instance of the comma operator. You can do the same thing in a for loop:
but that's still not it. The one place in Java where a comma can be used outside of a variable declaration or argument list is in for-loop initialization and increment code, like this:
That's the closest thing to C's comma operator there is in Java. Even so, it's not very close, because the values of any expressions are discarded and not used for anything.
Comma is one of the separators in Java, and it is used to define the formal grammar of the language. For a complete set of rules, see 18.1 The Grammar of the Java Programming Language. From the rules, you can identify all the cases when comma is used as a separator.