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 main string [] args?

534


Difference between stack and queue?

599


What is method in research paper?

588


Is string a data type in java?

601


What is java in detail?

575






What is the final keyword?

565


how are methods defined?

561


What are the different ways of creating thread?

580


What languages are pass by reference?

565


How do you compare characters in java?

531


How many bits are in a sentence?

601


What is methodological theory?

538


What is percentage in java?

583


Can we cast any other type to boolean type with type casting?

549


What are the differences between throw and throws?

540