Java Arrays convert element via Stream map()

Description

Java Arrays convert element via Stream map()


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

public class Main {
  public static void main(String[] args) {
    String[] strings = {"CSS", "HTML", "Java", "Javascript"};

    System.out.printf("Original strings: %s%n", Arrays.asList(strings));

    // strings in upper case
    List<String> list = Arrays.stream(strings)
             .map(String::toLowerCase)
             .collect(Collectors.toList());

    System.out.printf("strings:" + list);
 }
}



PreviousNext

Related