Java – isn’t it bad to import unused packages?
For example, when you work in a team with the same file, you can only partially understand the different packages required to import code You changed some code in this file and found that some code became redundant You delete this section and now don't know if the whole code still depends on all packages
[of course, bad can be objectified in many ways: speed, reading ability, etc.]
Solution
Yes There are two reasons:
>This can be confusing for people who see imported code that may or may not be used. > Multiple classes imported with the same name may have import conflicts This will require that all types except one of the similar class names can be referenced by fully qualified names in the code
For these reasons, Java will issue a warning if the import statement is not required and the IDE has a way to automatically delete unused imports
Note that I didn't mention speed or performance changes. I think javac is smart enough not to use any unnecessary imports, so the compiled class is like you didn't import it