This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes static import of enums Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "static import of enums" Watch "static import of enums" New topic
Author

static import of enums

tom mickey
Greenhorn

Joined: Aug 02, 2008
Posts: 9
Hi all,
I am having problems running the example code
at:
http://www.java2s.com/Code/Java/Language-Basics/Javastaticimportenum.htm

I get the following errors while compiling the code:

Can somebody point me what i have done wrong?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3036
    
    4

Put the whole shebang into a package, and import the fully qualified class name for Grade.



Steve
tom mickey
Greenhorn

Joined: Aug 02, 2008
Posts: 9
Thanks Steve.
It works now.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32675
    
    4
Look at this Java™ Language Specification page (§7.5) and look for "unnamed package" with ctrl-F. That may tell you why Steve Luke's solution works nicely.
tom mickey
Greenhorn

Joined: Aug 02, 2008
Posts: 9
I guess you are referring to section 7.5 where it states

It is a compile time error to import a type from the unnamed package

Thanks for clarifying, Campell.
Edit:
Ah! yes you are. didn't see those brackets while replying.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32675
    
    4
Yes, that's what I meant
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static import of enums
 
Similar Threads
Array Project Help
CActus problem
Scanner
Applet insights?
Range class