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


Please Help Members By Posting Answers For Below Questions

What do you mean by object?

532


What are methods in java?

524


What is an example of a constant variable?

516


Is oracle charging for java?

532


What is classes in java?

504






What is a variable and constant?

533


Can It is possible to synchronize the constructor of a Java Class?

583


Which data type is a class in java?

565


How to sort elements in a parallel array in java?

493


Explain the differences between abstraction and encapsulation?

506


What is string english?

525


Can a final method be overloaded?

495


What is instanceof keyword?

711


How do you write methodology?

548


Is arraylist ordered?

544