hi, can anyone tell me what ":" operator does and please explain the below condition statement?
for(String key:keyset) -----> what : operator does
Asked
Active
Viewed 60 times
-9
-
5google for `enhanced for loop`. – Pshemo Mar 06 '14 at 10:38
-
1https://blogs.oracle.com/CoreJavaTechTips/entry/using_enhanced_for_loops_with – Sionnach733 Mar 06 '14 at 10:38
-
1possible duplicate of [How does the Java for each loop work?](http://stackoverflow.com/questions/85190/how-does-the-java-for-each-loop-work) – Ashley Medway Mar 06 '14 at 10:58
-
Does not show any research at all. – Anders R. Bystrup Mar 06 '14 at 11:14
1 Answers
3
It's not an operator, it's just part of the syntax. What you see is the enhanced for loop or for-each loop. It iterates over keyset
and binds each string it contains to the variable key
one after another in each iteration.

André Stannek
- 7,773
- 31
- 52