Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: asterisk for loading classes

Tags:

java

memory

class

Is loading only the needed classes directly a good way of reducing the overall memory usage of a Java application?

For example:

import java.awt.Graphics;

vs

import java.awt.*;
like image 759
aardbol Avatar asked Nov 27 '22 15:11

aardbol


1 Answers

No. You should import only the needed classes to make it clear to programmers which classes are actually needed by your class.

Import statements just tell the compiler where to look for the classes you are using - it doesn't mean all the classes in the package are loaded into memory.

like image 134
brabster Avatar answered Dec 17 '22 15:12

brabster