0 votes
in Education by (54.6k points)

How will you sort a list of string using Java 8 lambda expression?

1 Answer

0 votes
by (54.6k points)
How will you sort a list of string using Java 8 lambda expression in Java8?

Following code sorts a list of string using Java 8 lambda expression:

//sort using java 8

private void sortUsingJava8(List<String> names) {

  Collections.sort(names, (s1, s2) -> s1.compareTo(s2));

}
...