This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 41089
    
  44
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Anonymous Classes Implementing An Interface Issue
 
Similar Threads
Cyclic class
More about Separated Interface Pattern and layered design
Can't understand the Output
Java beginner- interface
Why public?