what does it mean when one says, "a single-type import will take precedence over an import-on-demand" moreover what do we mean by single type import?? import-om demand?? what's the difference b/w above two?? Thanks in advance Lusha [This message has been edited by lusha tak (edited May 27, 2001).]
When you use the import statement, you can import the exact thing that you need and no more (the exact class name for example). You can also refer to whole class and have the system import what is needed in the class when it needs it. When you use the class in you program, it will look in the import <...>.* and locate what you need. Hope this clears it up.
Originally posted by Scott Appleton: I'm not sure what is meant by "take precedence". You can have both types of imports in a single source file. Anyone able to explain the meaning of this statement?
Probably means that if you had a Foo class in two different packages, e.g. package1 and package2, then import package1.Foo; import package2.*; Foo f = new Foo(); // pulls in package1.Foo, not package2.Foo
Hi all, When determining which class to use, the compiler follows a set of 'lookup' rules. First it checks the source file for the type, then it looks for a single-type import that matches the classname, then it checks the import-on-demand packages. It stops checking when it finds a type that matches the required one; if no class is found or the declarations are ambiguous, you get a compile error See JLS �6.5.5 Meaning of Type Names Hope that helps. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform [This message has been edited by Jane Griscti (edited May 29, 2001).]