Java8-Stream-No.02

mac2022-06-30  114

import java.util.ArrayList; import java.util.List; public class Streams2 { public static void main(String[] args) { List<String> stringCollection = new ArrayList<>(); stringCollection.add("ddd2"); stringCollection.add("aaa2"); stringCollection.add("bbb1"); stringCollection.add("aaa1"); stringCollection.add("bbb3"); stringCollection.add("ccc"); stringCollection.add("bbb2"); stringCollection.add("ddd1"); // sorting stringCollection .stream() .sorted() .forEach(System.out::println); System.out.println(stringCollection); } }

转载于:https://www.cnblogs.com/bilaisheng/p/10210936.html

最新回复(0)