anonymous inner classes

>>>Inner classes can be created within methods. This is something that GUI builders like Borland JBuilder do a great deal of when creating Event handlers.

Here is an example of such automatically generated code

buttonControl1.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
        buttonControl1_mouseClicked(e);
      }
    });



>>>


As you might guess an anonymous class cannot have be given a constructor by the programmer. Think about it, a constructor is a method with no return value and the same name as the class. Duh! we are talking about classes without names. An anonymous class may extend another class or implement a single interface



>>>A class defined within a method can only access fields in the enclosing method if they have been defined as final. This is because variables defined within methods normally are considered automatic, ie they only exist whilst the method is executing. Fields defined within a class created within a method may outlive the enclosing method.






I was reading above lines from link
http://www.jchq.net/certkey/0401certkey.htm

did not understand it clearly.


 Any ideas, resources,sample code,links,  highly appreciated. thanks in advance.
LVL 7
gudii9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
The language spec is always the final authority on these issues:

http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#252986
0
gudii9Author Commented:
>>> variables defined within methods normally are considered automatic,

why these variable defined in method called automatic

>>>Fields defined within a class created within a method may outlive the enclosing method.

what it mean. please advise
0
CEHJCommented:
>>why these variable defined in method called automatic

Because they are allocated and de-allocated automatically as the program runs

>>Fields defined within a class created within a method may outlive the enclosing method.

If another object gets a reference to them as it executes, it will hang on to them until they can be garbage collected
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.