Java Arrays create Stream from array

Description

Java Arrays create Stream from array


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

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

       List<String> list= Arrays.stream(array)
                  .filter(s -> s.compareToIgnoreCase("Java") > 0)
                  .sorted(String.CASE_INSENSITIVE_ORDER.reversed())
                  .collect(Collectors.toList());
       /* ww w  .  ja v a2 s .  co m*/
       System.out.println("strings greater than m sorted descending:"+list);

   }
}



PreviousNext

Related