Linked Questions

198 votes
9 answers
62k views

Suppose I have a method that returns a read-only view into a member list: class Team { private List<Player> players = new ArrayList<>(); // ... public List<Player> ...
fredoverflow's user avatar
83 votes
7 answers
61k views

Stream doesn't have a last() method: Stream<T> stream; T last = stream.last(); // No such method What's the most elegant and/or efficient way to get the last element (or null for an empty ...
Bohemian's user avatar
  • 427k
36 votes
5 answers
4k views

Environment: Ubuntu x86_64 (14.10), Oracle JDK 1.8u25 I try and use a parallel stream of Files.lines() but I want to .skip() the first line (it's a CSV file with a header). Therefore I try and do ...
fge's user avatar
  • 122k
5 votes
1 answer
6k views

A question about spliterators that at first glance is not straightforward. In streams, .parallel() changes the behaviour that the stream is processed. However I was expecting the spliterators created ...
Tet's user avatar
  • 1,205
5 votes
1 answer
3k views

Every time when I get a coding interview, I always avoid using Java stream, because I can't analyze the time complexity very well. For example: in my daily work, I might write like this: Arrays.stream(...
Timmy Lin's user avatar
2 votes
2 answers
971 views

The hashmap has two key and value pairs, they are not processed in parallel by different threads. import java.util.stream.Stream; import java.util.Map; import java.util.HashMap; class Ideone { ...
Kamel's user avatar
  • 1,866
4 votes
2 answers
145 views

I was thinking about an answer to the question: How to test for null keys on any Java map implementation? My first thought was to check if the Spliterator of the keyset of a map has the ...
LuCio's user avatar
  • 5,223
4 votes
1 answer
163 views

from this question a spliterator reporting either, IMMUTABLE or CONCURRENT, is guaranteed to never throw a ConcurrentModificationException. Of course, CONCURRENT precludes SIZED ...
amarnath harish's user avatar
5 votes
0 answers
179 views

After the first question about understanding deeply java streams spliterators here, another subtle question about streams: Why the implementation of .flatMap() in Java is so inefficient (non lazy)? ...
Tet's user avatar
  • 1,205
3 votes
0 answers
40 views

Spliterator interface defines a number of characteristics: A Spliterator also reports a set of characteristics() of its structure, source, and elements from among ORDERED, DISTINCT, SORTED, SIZED, ...
Anton Balaniuc's user avatar