Re: import statement
varun chadha wrote:
when we use import statement such as:
import java.util.*
or any such, we are referring to the java/util/*.class classes. but
Yes.
where is this package located in my jdk directory. Also i dont need
to
It's system dependent, I think, but on my system it's in
jre1.6.0_07/lib/rt.jar . That .jar file has all the standard API
classes. It's just a zip file, so I guess you could unzip it and take a
look at the contents.
import statement works non-recursively. i.e we have to write two
Yes, import is "non-recursive."
so for following directory structure:
javacode/
Hello.class
otherclasses/
Welcome.class
is this statement wrong in Hello.java:-
import Welcome.class;
Something else that is wrong is that the package of Welcome.class must
be "otherclasses". Java does not work by directory names. That's just
how it finds classes. Welcome class must be defined as:
package otherclasses;
public class Welcome { //... etc.
}
Or the directory structure is wrong. Packages and directories must
match or the loading will fail.
If Welcome.class is declared in the package "otherclasses" *AND* it's in
the directory you say above *AND* "javacode" is included in the
classpath, then the class can be loaded.