https://grokonez.com/java/java-8/how-to-use-java-8-stream-map-examples-with-a-list-or-array
How to use Java 8 Stream Map Examples with a List or Array
[no_toc]
Converting or transforming a List and Array Objects in Java is a common task when programming. In the tutorial, We show how to do the task with lots of Java examples code by 2 approaches:
Now let’s do details with examples!
Related posts:
package com.grokonez.stream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class StreamMapExamples {
public static void main(String[] args) {
List intLst = Arrays.asList(1, 2, 3, 4);
// How to double value for each element in a List
// n -> n*2
List newLst = new ArrayList();
for(int i : intLst) {
newLst.add(i*2);
}
System.out.println(newLst);
// [2, 4, 6, 8]
}
}
https://grokonez.com/java/java-8/how-to-use-java-8-stream-map-examples-with-a-list-or-array
How to use Java 8 Stream Map Examples with a List or Array
#java #java8 #stream #array