Transform Stream using

The map() method is an intermediate operation. It returns a stream consisting of the results of applying the given function to each element in the stream.

The following code returns a stream of Integers, which are results of applying String.length() method.

import java.util.ArrayList;
import java.util.List;
public class Java8Map {
	public static void main(String[] args) {
		List<String> list = new ArrayList<String>();
		//map function
		Stream<Integer> stream = -> p.length());
		Integer[] lengthArr = stream.toArray(Integer[]:: new);
		for(int a: lengthArr){
Category >> Java 8 >> Stream  
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
String foo = "bar";
  • Alex Green

    What is