aspose file tools*
The moose likes Beginning Java and the fly likes Anonymous Classes Implementing An Interface Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Anonymous Classes Implementing An Interface Issue" Watch "Anonymous Classes Implementing An Interface Issue" New topic
Author

Anonymous Classes Implementing An Interface Issue

Ehsan Rahman
Ranch Hand

Joined: Feb 16, 2009
Posts: 59

Hi Everyone,

Hope you are having a good day/night. Stumbled upon another anonymouse class issue:



Please could someone explain why assignment to A works but the assignment to B (by not assigning immediately) doesn't work.

Many Thanks,
Ehsan


SCJP 1.5, SCJD 1.6
Chad Cook
Greenhorn

Joined: Dec 02, 2004
Posts: 29
What error message(s) are you receiving?
Ehsan Rahman
Ranch Hand

Joined: Feb 16, 2009
Posts: 59

When compiling:



The following compiler error message appears:

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42286
    
  64
You can't have code (like an assignment) outside of methods, unless they're part of a field declaration, or in a static initializer.


Ping & DNS - my free Android networking tools app
 
jQuery in Action, 2nd edition
 
subject: Anonymous Classes Implementing An Interface Issue