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

understanding J2SE 5.0 Enum

Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
I'm coming from the C# world where I can write an enumerated type like so:

...and then call it from another class like so, and it would work:

However, I get an error (Eclipse) telling me "QueryType.STORED_PROCEDURE cannot be resolved". Code-hinting reveals that I all have available to me from the QueryType type is "QueryType.class" and "QueryType.this"...both of which don't make any sense to me.

I'm expecting to be able to call the enum values in a static fashion but I can't!?

I have an import reference to it, that's not the problem...

Documentation on the net is dirt poor and I can't find one good solid example.

Can anyone help me out?

R�mi Forax

Joined: Oct 10, 2004
Posts: 3
It's an eclipse bug !

for now, eclipse (3.1M2) doesn't understand enum correctly.
Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
You've gotta be kidding me!?

Is there a fix yet? A newer version than M2 w/ an update to this problem?
Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
So, obviously eclipse has the same problem w/ "VarArgs"?

This should be correct yet eclipse is telling me it's a no-no.

Eclipse says:

Can only iterate over an array or an instance of java.lang.Iterable

According to the Java book I bought, this should work...
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
This is always a problem when using features that are new to the latest release of a language. The version of Eclipse you are using is compling your code with the 1.4 compiler and you are using 1.5 features. If you have Ant installed, you can get around this by writting a build script that defines which compiler to use and run the Ant script from Eclipse.
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Originally posted by R�mi Forax:
It's an eclipse bug !

Actually it's not a bug - it's work in progress.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link:
subject: understanding J2SE 5.0 Enum
It's not a secret anymore!