I think I am missing something fundamental here. I have the understanding that when you have an import statement like: import something.somethingElse.*; that imports all classes in the somethingElse package. But sometimes I get an error unless I explicitly say import something.somethingElse.MyClass; Can someone tell my why I sometimes have to explicitly list the class and othertimes package.* works? Thanks in advance!
Joined: Mar 15, 2000
I don't know if this is the answer but sometimes I make mistakes here by assuming that .* will import ALL subdirectories. It only imports the files that are in this particular directory.
import com.mystuff.*; will not import the following class com.mystuff.classes.myFirstClass but it will import com.mystuff.mySecondClass
Hope this helps..... Paul
Joined: Oct 31, 2000
Paul's right. I just thought I'd add, that's why, if you ever use event listeners with the AWT, you have to say at the beginning of your class:
You won't get away with just:
Joined: Sep 29, 2000
Also there are cases where more than one class that you are importing contains a class with the same name. Import java.util.*; Import java.sql.*; Now when you want to use the Date class, you have to explicitly name which Date that you want to use.
"JavaRanch, where the deer and the Certified play" - David O'Meara