Anonymous inner class vs Lambda Expression

Anonymous:

The Class without having name is calles Anonymous class. Anonymous inner class can nextend a class and implements an interface.

Q. When to use Anonymous inner class?

Anonymous inner class can be used for instant use.

Ex:

Ex- 2

Ex —

// without Lambda expression

// with Lambda expression

Annonymous inner class !=Lambda expression.

if Annonymous inner class implements an interface that contaions single abstract method then only we can ewplace that Annonymous inner class with lambda expression.

Anonymous inner class can extend a normal class.

Anonymous inner class can extend an abstract class.

Anonymous inner class can implement an interface which contains any no.of abstract methods.

Lambda expression can implement an interface which contains a single abstract method.(Functional interface).