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

Is multiple inheritance supported by java?

483


What is numel matlab?

624


If an object is garbage collected, can it become reachable again?

520


What is the properties class?

539


What is a boolean structure?

533






What is a stack class in java ?

584


What is literal example?

539


Is integer passed by reference in java?

540


What do you mean by chromounits in java8?

504


What does %d do in java?

550


What is anti pattern in programming?

475


Why for each loop is used?

484


What is meant by javabeans?

585


What is the purpose of using bufferedinputstream and bufferedoutputstream classes?

524


What are format specifiers in java?

567