[JAVA] Importing package interfaces vs. entire package

XXXconanXXX

Cocktails anyone?
Reaction score
284
Is there any reason to import specific package interfaces instead of the entire package? Does it take longer to call all classes when you import the entire package?

EG:

import java.awt.Graphics;

instead of

import java.awt.*;
 

UndeadDragon

Super Moderator
Reaction score
447
I believe it increases the filesize of the application. (Correct me if I'm wrong)
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
It shouldn't increase the file size. The libraries are not compiled like in C/C++ where adding, let's say iostream, increases the file size. All the libraries are in every computer that has Java, exactly like .NET. And it shouldn't slow alot as it does not import all the classes, it just tells where to search for the classes when they're used.

The bad side of this is that you decrease the number of classes names.
Code:
import java.awt.*;

class Frame {
// error 2 classes with same name
}
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top