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

Open 1 Answers 17 Views Education

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

1 Answer

0
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));

}
by (52.6k points)
...