This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question on Static import!! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Question on Static import!!" Watch "Question on Static import!!" New topic
Author

Question on Static import!!

Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1803
static imports:
===============



Krishna Srinivasan
OCAJP Mock Questions
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8876

Nice question. Brett's Devloper notes has a good explanation

1 is the answer The same question could be extended to static methods.


Groovy
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1803
Surprising Static Imports
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1803
few tips on static import:

Two types of static import declarations:

1)single-type import declaration.
example:
import static Enum.EnumMember.Java;
2)static import on demand.
example:
import static Enum.EnumMember.*;


On-demand-static import never shadow the previous imports declarations.
example:
import static Enum.EnumMember.Java;
import static Enum1.EnumMember.*;

In the above example both the enum type has the variable Java.When we are usiing
the on-demand-static-import(import static Enum.EnumMember1.* .It will not shadow
the previous declaration import static Enum.EnumMember.Java;

But two single-type static imports trying to import the same variable, the compile
time error occurs.

example:
import static Enum.EnumMember.Java;
import static Enum1.EnumMember.Java;
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on Static import!!
 
Similar Threads
Run time error
Giving runtime error
How to call method which was in enum class
Trouble with enums on practice tests
Error in Package