| 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
|
|
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
|
|
|
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
|
|
Yes, that's what I meant
|
 |
 |
|
|
subject: static import of enums
|
|
|