---
type: archive
area: archive
status: archived
date: 2026-05-03
created: 2026-05-03
updated: 1980-01-01
tags:
  - archive
---
![[img-20240814-143318-255348f5.png]]
## Lambda Expression
![[img-20240814-144403-36b0349f.png]]

![[img-20240814-145418-1ab56107.png]]

- thenComparing: add additional comparators
- reversed reverses sorting order
- Predicate interface 
- We can sort using specific sorting type by passing comparator condition as parameter to sort method of a list without the class should implement Comparable interaface.
- when a class implement comparable interface and override compareTo method we should use Collections.sort() an it will automatically sort based on this methods

- In Java, interface methods traditionally have no body and must be implemented by any class that implements the interface. However, with the introduction of **default methods** in Java 8, interfaces can now include methods with a default implementation.

### `default` Access Modifier

- The `default` keyword in an interface method allows you to provide a default implementation for the method directly within the interface.
- Classes that implement the interface are not required to override the method. If they don't, the default implementation will be used.
- This is particularly useful when you want to add new methods to an interface without breaking the existing implementations.