Lesson 33 of 34
Sorting, Comparators and Lambdas
10 min 35 XP
Collections.sort() sorts numbers and Strings. To sort objects you need a Comparator. A lambda like (a, b) -> ... writes a small method in one line.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.Streams let you filter and transform collections in a few words. Modern Java interviews ask about them often.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.