In Java 8 we have the class Stream<T>, which curiously have a method Iterator<T> iterator() So you would expect it to implement interface Iterable<T>, which requires exactly this method,...
  • May 17, 2022
  • 0 Comments
If I have a collection, such as Collection<String> strs, how can I get the first item out? I could just call an Iterator, take its first next(), then throw...
  • May 13, 2022
  • 0 Comments
In my application I use 3rd party library (Spring Data for MongoDB to be exact). Methods of this library return Iterable<T>, while the rest of my code expects Collection<T>....
  • May 4, 2022
  • 0 Comments
I have an interface which returns java.lang.Iterable<T>. I would like to manipulate that result using the Java 8 Stream API. However Iterable can’t “stream”. Any idea how to use...
  • May 4, 2022
  • 0 Comments