This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Both imports work for enums ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Both imports work for enums ?" Watch "Both imports work for enums ?" New topic

Both imports work for enums ?

Sreedevi Vinod
Ranch Hand

Joined: Jan 17, 2005
Posts: 117
I thought that only static import can be used to import static members of a class. And enums are static by default.
In the below code, I can replace the 'static import' with a normal import to use the enum which is defined inside EnumClass.
Still it works fine. Why so ?

Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

The 'static import' construct is only a convenience. It is never required.

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Sreedevi Vinod
Ranch Hand

Joined: Jan 17, 2005
Posts: 117
Thanks, but what I meant to ask is that there are some things you can do with static imports and not with normal imports - like importing static methods and variables of a class. But in the case of enums (as class members),both imports work, why is it so ?
[ September 13, 2005: Message edited by: Sreedevi Vinod ]
I agree. Here's the link:
subject: Both imports work for enums ?
It's not a secret anymore!