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 is the purpose of using the java bean?

566


Why singleton class is used in java?

566


What is the platform?

528


How do you sort an array in java?

535


Can a static member function access member variable of an object?

554






What is the default value of byte datatype in java?

480


why an outer class cannot be declared as private?

3610


How can you make sure that your singleton class will always return single instance in multi-threaded environment?

568


if u open login & logout ,how can udisplay the timelogin & logout members ?

1753


What is an class?

590


What is the benefit of inner classes in java?

603


What is meant by design patterns?

579


How to display all the prime numbers between 1 and 100

499


What are the approaches that you will follow for making a program very efficient?

640


What is mean by collections in java?

562