Java – using import some directory.* Worse performance?

What is better performance use

import some.directory.*;

or

import some.directory.classNeeded;

Or is there no performance change because the compiler discounts unused libraries in the class? So it's for convenience?

Solution

The import statement is completely unnecessary If you like, you can be like a java developer without writing one; It just means that you will be forced to enter a fully qualified class name for each class in your application

All imports allow you to use short class names instead of fully qualified names in your code (for example, connection instead of Java. SQL. Connection)

If your class has two packages with the same short class name, you must always type them to eliminate all ambiguities (for example, Java. SQL. Date and Java. Util. Date)

Do not confuse import with class loading It does not affect runtime performance at all; It only affects the number of keys you enter during development

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>