What is the use of anonymous inner classes ?
Answer Posted / reddy vatti
The use of anonymous inner classes is to access the data of
outer class.Even private data also we can access.
button.addActionListerner(new ActionListener(){
public void actionPerformed(){}
});
here we are using anonymous class to implement
ActionListener interface.If at all we are using other class
that implements ActionListener interface and passing that
obj into
button.addActionListener(obj);
In this method we cant access the private variables of the
class that call button.addActionListener();
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Give the difference between the println method and sqrt method?
What are the problems faced by java programmers who don't use layout managers?
What is a method in programming?
What is string :: npos?
How do you add an element to an arraylist in java?
Is arraylist ordered?
What's the difference between int and integer in java?
Is zero a natural number?
What are the advantages of java?
What is the difference between static method and instance method in Java?
What is connection class in java?
Can we create object of inner class in java?
What is string length in java?
what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread
What is the difference between access specifiers and access modifiers in java?