Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Anonymous Classes Implementing An Interface Issue

 
Ehsan Rahman
Ranch Hand
Posts: 59
Chrome Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Chad Cook
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error message(s) are you receiving?
 
Ehsan Rahman
Ranch Hand
Posts: 59
Chrome Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When compiling:



The following compiler error message appears:

 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't have code (like an assignment) outside of methods, unless they're part of a field declaration, or in a static initializer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic