I know that that on can have a class declaration in a method of class.
Eg. We can have anonymous class declaration for event handling in a method body.
But I want to know that same way can I have Interface declaration in a method in a class.
What is use of that?
I’ assuming you are refering to returning an interface for a method?
Short answer: Yes.
Why?
Here’s a good post.
Why we return type Mostly Interface rather than Class?
Excerpt: