This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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!
Paul Keohan
Ranch Hand
Joined: Mar 15, 2000
Posts: 411
posted
0
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
Art Metzer
Ranch Hand
Joined: Oct 31, 2000
Posts: 241
posted
0
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:
Art
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
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