aspose file tools*
The moose likes Beginning Java and the fly likes static import of enums Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
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: 4181
    
  21

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: 38851
    
  23
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: 38851
    
  23
Yes, that's what I meant
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static import of enums