General discussion

Locked

imports for java

By tmanavalan ·
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.

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

imports for java

by Ann777 In reply to imports for java

Generally you need them both. Yes, the second loads the whole package. But the first defines specifically where it needs to look for the exception. See the below example for more info:

http://www.daimi.aau.dk/~bouvin/otw/rmiexample.html

Collapse -

imports for java

by tmanavalan In reply to imports for java

Poster rated this answer

Collapse -

imports for java

by port8080 In reply to imports for java

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.

Collapse -

imports for java

by port8080 In reply to imports for java

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.*;

Collapse -

imports for java

by tmanavalan In reply to imports for java

Poster rated this answer

Collapse -

imports for java

by tmanavalan In reply to imports for java

This question was closed by the author

Back to Web Development Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums