Java_Interview_QA
Java_Interview_QA
## Lambda Expressions
anonymous class?
Anonymous classes, on the other hand, allow you to define and instantiate a
class at the same time. While both can be used to provide behavior, lambda
expressions are more readable and compact, as they do not require the
creation of a class.
Example:
- Anonymous Class:
```java
@Override
System.out.println("Running");
}
};
```
- Lambda Expression:
```java
```
```java
import java.util.*;
list.forEach(System.out::println);
```
---