• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown

Difference between forEach and forEachRemaining

Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Could anyone tell me the difference between Stream.forEach() and Iterator.forEachRemaining() methods?

The explanation in java docs says "Performs the given action for each remaining element until all elements have been processed or the action throws an exception.".

I got confused with this explanation. Does it mean that it will iterate and perform the action that we apply on remaining elements when iterator is in the middle?

Could someone please clarify?

Thanks, Raghu
    Bookmark Topic Watch Topic
  • New Topic