File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What happen when import the same package more than one time in the given class.

 
Achyut Behera
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried it?
 
Joanne Neal
Rancher
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
imports are only used by the java compiler, not by the JVM, so they will have no effect on how many classes are loaded.
 
Ninad Kulkarni
Ranch Hand
Posts: 802
Hibernate Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic