Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
vin kum
3,546 PointsQuestion about Map.Entry ?
In the maps lesson, the instructor uses for( Map.Entry: examples.entrySet()){ //other code that I understood }
I did not understand the parameters in the for syntax. Thanx for the help.
1 Answer
Craig Dennis
Treehouse TeacherHi vin kum !
That is what is known as the enhanced for loop.
String[] fruitBasket = {"apple", "banana", "cherry"};
// This can be read as for each fruit in fruitBasket.
for (String fruit : fruitBasket) {
System.out.println(fruit);//... The first time this prints "apple", then "banana"
}
It's a handy way to iterate over a collection of items.
Does that clear things up?
vin kum
3,546 Pointsvin kum
3,546 PointsNo it did not, sorry if I was not clear. What I meant is I did not understand what Map.Entry entry does and examples.entrySet() does?
Thank you!