Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

accessing methods using enum  RSS feed

 
Chandra shekar M
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,



 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In #1 you're defining a method in the SingleTone class, so it's accessible through any reference to a SingleTone.

In #2 and #3, hi() is not defined in SingleTone, but rather in anonymous inner classes (Or something roughly equivalent to them. I forget the details of how that works out in enums.)

If you want #2 and #3 to work, you have to do it something like this:


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!