D
D
DarkByte20152017-06-17 14:45:48
Java
DarkByte2015, 2017-06-17 14:45:48

Stream foreach-range-loop?

Can you please tell me why it is not possible to do a for ( : ) loop over a Stream from Java 8? They are like iterable. Those. they also have an iterator method, due to which you can make a regular for ( ; ; ) loop, but on for ( : ) it swears. :( "foreach not applicable to type Stream"
PS I know that streams have a forEach method, but I needed just the usual foreach. If only because if the method reference that I put there throws an exception, it starts to swear at it and requires do a try/catch. And I need this exception to be thrown up, and not processed inside the lambda. In the end, I used an iterator that can be obtained from the stream and made a regular for ( ; ; ) loop ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DarkByte2015, 2017-06-17
@DarkByte2015

It seems understood... The method iterator is, but from Iterable it is not inherited. In short, streams in java are done through the ass. Like everything else though...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question