Is it possible to delete any implicitly imported Java library?

Is it possible to delete any implicitly imported Java library? This may seem inappropriate. But I think it can shorten the execution time!

+3
source share
3 answers

Import is just syntactic sugar. All they do is access things in other packages without specifying their full name. The code that is generated is exactly the same as if you had fully qualified everything. Thus, there is no performance limitation on import for execution.

This also applies to "implicit imports" (that is: java.lang): you do not pay any price for classes that you are not actually using.

+22

- , , , , , .

, Visual VM , ( ).

+4

Java does not include all classes in java.lang. * in your program. The compiler includes only those that you explicitly use (or are used by the classes you use, etc.).

+3
source

Source: https://habr.com/ru/post/1715427/


All Articles