| Author |
What happen when import the same package more than one time in the given class.
|
Achyut Behera
Greenhorn
Joined: Mar 09, 2009
Posts: 17
|
|
Hi All,
Suppose i have a class name "Animal" in some package;
and one more class "Dog" in some other packages.
What happens if i import the animal class more than one time in Dog class.
The animal class will be loaded twice or what?
Please tell me internally what happens?
Thanks,
Achyut
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
|
Have you tried it?
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
|
imports are only used by the java compiler, not by the JVM, so they will have no effect on how many classes are loaded.
|
Joanne
|
 |
Ninad Kulkarni
Ranch Hand
Joined: Aug 31, 2007
Posts: 774
|
|
If you know the meaning of import statement then you will know what happens if you import the animal class more than one time in Dog class.
The class using import statement
You can use just File
Same class without using import statement
You have to use fully qualified java class name
The import means you don't have to write fully quallified java class name.
Its for our convinience to use in coding.
|
SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
|
 |
 |
|
|
subject: What happen when import the same package more than one time in the given class.
|
|
|