File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes accessing methods using enum Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "accessing methods using enum" Watch "accessing methods using enum" New topic

accessing methods using enum

Chandra shekar M
Ranch Hand

Joined: Dec 20, 2006
Posts: 155
Hi All,

Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

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:

I agree. Here's the link:
subject: accessing methods using enum
It's not a secret anymore!