Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static import of enums

 
tom mickey
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the whole shebang into a package, and import the fully qualified class name for Grade.

 
tom mickey
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Steve.
It works now.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's what I meant
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic