..........
well, let me tell you i made some mistakes: the foreach() i was refering to is not an aggregate operation but a method from Iteable. I've changed the title of my question and its content.
My interest is to know if an aggregate operation is implemented by default and Where i can find that implementation.
If you want to dig into the JDK sources you can always download them here as @jbkm suggest. If you have the Oracle JDK installed, there should be
src.zip
file in the installation folder which contains all the public sources. Alternatively you can check the OpenJDK sources online, for example, on GrepCode. As you can see, the implementation offorEach
forIterable
is quite simple:If you're asking about the implementation of
forEach
in the Stream API, it's much more tricky thing as it should evaluate all the previous pipeline steps and perform the operation in parallel for parallel streams. You can start your investigation examining theReferencePipeline
class which is theStream
implementation in OpenJDK.