Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Aditi Msc   on Jul 02 In Java Category.

  
Question Answered By: Jay Richards   on Jul 02

There is not any penalty when you use one of
the three possible ways to reference a class
name.

The only thing we are doing with "import" is
telling to the compiler for what classes we dont
want to write the complete name, just that
(Remember that the complete name of a class is
the name it self plus the name of the package)

All of these ways are solved at compile  time,
not at run time, so there is not any
difference at run time.

The three ways, for a class named "MyClass" in a
package named "myPackage", are these:

1) To use the complete name of the class:
myPackage.MyClass a = new myPackage.MyClass ();

2) To use import  with *;
import myPackage.*;
...
MyClass a = new MyClass ();

2) To use import with the class name;
import myPackage.MyClass;
...
MyClass a = new MyClass ();

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on import time Or get search suggestion and latest updates.


Tagged: