Home / JAVA Complete Reference by Examples / Streams / How to transform stream elements using map in Java 8 by Example
How to transform stream elements using map in Java 8 by Example
1926 views.
package com.learnbyexamples.streams;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class E007_TransformStreamUsingMap {
    public static void main(String[] args) {
        //List of names
        List<String> names = new ArrayList<>();
        names.add("JOHN");
        names.add("PETER");
        names.add("SHIVA");
        
        //Transform all strings into lowercase
        List<String> lowerNames = names.stream().map(String::toLowerCase).collect(Collectors.toList());
        
        //Prints the list
        System.out.println(lowerNames);
    }
}
Output
[john, peter, shiva]
Related Examples
   How to filter an List stream using Lambda expression in Java 8 by Example
   How to filter an Array stream using Lambda expression in Java 8 by Example
   How to filter an Map stream using Lambda expression in Java 8 by Example
   How to use Stream generate method using Lamdba expression in Java 8 Example
   How to read a file line by line using stream in Java 8 by Example
   How to split string into stream in Java 8 by Example
   How to transform stream elements using map in Java 8 by Example
   How to use flatMap stream method in Java 8 by Example
Copyright © 2016 Learn by Examples, All rights reserved