+ 2

What is anonymous class and inner class?

16th Apr 2017, 4:34 AM
Nikhil
Nikhil - avatar
4 Respuestas
+ 13
As per I know, anonymous class is one which have no name. We can pass the object of anonymous class as parameter to some function. Inner class is a class that can be defined in a class. I'm not sure. Correct me if I'm wrong
16th Apr 2017, 5:13 AM
Sachin Artani
Sachin Artani - avatar
+ 12
IN JAVA : - A class that have no name is known as anonymous inner class in java. It should be used if you have to override method of class or interface.
16th Apr 2017, 4:46 AM
Don MTY
Don MTY - avatar
+ 7
Class with no name:-Anonymous class Class inside a class:- Inner class
16th Apr 2017, 5:20 AM
Meharban Singh
Meharban Singh - avatar
+ 5
class A { class AnInnerClass { } public Runnable getRunnable() { return new Runnable() { public void run() { // This is an anonymous class } } } }
16th Apr 2017, 6:22 AM
Tamás Barta
Tamás Barta - avatar