Passing a small piece of behaviour, like "compare by length", used to need a whole anonymous class. A lambda lets you write that rule in one line, which makes sorting, filtering and callbacks much shorter. Use it for short logic passed into methods such as sort or forEach. When the logic grows past a few lines, move it into a named method so it stays readable.