TapThat TapThat - 1 year ago 90
Java Question

What topic does this fall under?

On another forum I found a solution to my problem, converting an ArrayList to int[]. The solution was simply brilliant, so I'd like to read more upon it - But I don't know where to look. Could someone guide me as to what the following falls under:

int[] arr = list.stream().filter(i -> i != null).mapToInt(i -> i).toArray();

I understand it may fall under multiple topics - that's fine. The individual who wrote this highlighted this is only present as a result of Java 8.

To link you to the answer directly: how to convert an arrayList to intgers

Apologies if this is a vague question, I just don't know what area of Java to look into.

Thank you!!

Answer Source

Basically ,they are Java8 streams, which will be helpful to process (filter/aggregate/group) the data from collections (list/set/etc..).

Java Collections(List/Set/Map/etc..) are just data structures which can be used to store the data.

Java Streams provide advanced methods to process (filter/aggregate/group i.e., to perform sql like operations) the data from Collections.

Please start with the below tutorial to get more on this: http://www.oracle.com/technetwork/articles/java/ma14-java-se-8-streams-2177646.html

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download