• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

accessing methods using enum

 
Chandra shekar M
Ranch Hand
Posts: 162
  • 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:


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic