Discussion Locked

imports for java

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

i just need to know if there is any difference in memory handling between this two statements thank you

1. import java.rmi.RemoteException;
2. import java.rmi.*;

i need to know if the second one loads all the class in the rmi pacake or onlywhat i need. should i put every class file in its own line or should i just use a * thank you.

6 replies

by port8080

Yes the second one will load all the classes in the package. Using * makes more sense as with newer versions of the JVM there is not much overhead associated with it.

by port8080

You may want to keep in mind that the * will only load all the classes directly under rmi. For classes further below in hierarchy you will have to make an additional reference and so on.

e.g
import java.rmi.*;
import java.rmi.server.*;

This discussion is closed to new replies.