"PageV" wrote...
> Array2.class is in .\com\bruceeckel\util. Array2.java is in .\
> I am wondering why the compiler looks at Array2.java at all.
The compiler doesn't *know* that Array2 is supposed to be
com.bruceeckel.util.Array2. In your code it's only named as Array2, which
*could* mean that it is in the default package (.\) or in java.lang (which
is "imported by default").
> Shouldn't it find Array2.class, which it does do
> if I rename or remove Array2.java?
As it doesn't know if it is in the default package, java.lang or
com.bruceeckel.util, it looks for it in all three places.
As it finds Array2.java in .\ first, but without corresponding .class in the
same directory, it simply believes that it has to compile it.
Then it discovers that the current location of the .java file doesn't
correspond to what is said inside, that it belongs to package
com.bruceeckel.util, and hence an error occurs.
As it already found a possible .java-file, it doesn't look further to see if
there is an Array2.class or Array2.java in the other directories, but as you
noticed, if it *doesn't* find it in the "default package", it continues to
search, and finds the class-file in the correct directory.
Here is another explanation of the implications:
http://www.kevinboone.com/classpath.html
// Bjorn A
PageV - 22 May 2004 02:52 GMT
> "PageV" wrote...
> >
[quoted text clipped - 28 lines]
>
> // Bjorn A
Thanks
Ralph