The java.util.stream is a sequence of elements supporting sequential and parallel aggregate operations.
The Stream.sorted() method returns a sorted Stream.
Java 8 stream sorted method example
package com.w3schools; import java.util.stream.Stream; public class Test{ public static void main(String[] args) { Stream.of("Jai", "Mahesh", "Vishal", "Naren", "Hemant") .sorted() .forEach(System.out::println); } }
Output
Hemant Jai Mahesh Naren Vishal