wood burning stoves 2.0*
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
Author

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?

Thanks!
R�mi Forax
Greenhorn

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
author
Sheriff

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: understanding J2SE 5.0 Enum
 
Similar Threads
generic enum and the values() method
Enum Type inhteritance
Cannot understand enum class syntax
java.util.Date as parameter in servlet
Enums (Is this the best way)?