• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Extended For Loop  RSS feed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have defined a class called ElectricalPart. I have also defined the following variable:

I would like to write something like a pair of for loops to process each member of the map. Would doing it with one for loop be better. How would I do that?

Bob
 
Bartender
Posts: 1664
37
Eclipse IDE Google Web Toolkit Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure what an extended for loop means. I am aware of an "enhanced" for loop. Have a look at my code below:



 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Who wants a loop when you can get a Stream out of the Map? You can get one of the three Collection views of the Map or use the whole Map; look in the Java™ Tutorials.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!