I have a class which uses HashMap and I have imported import java.util.HashMap.
On executing reformat code -> eclipse shortcut used Cntrl+Shift+R
It reformats and convert to import java.util.*
Why android studio imports all classes if we need only one , here HashMap? Isn't it unnecessary.
If any package is having more than N numbers of import of the same package in Android studio, it automatically converts it to *
imports for that package (default are 5 for Top-level Symbols and 3 for Java Statics and Enum Members).
So, for example if you're having some N number of imports from package java.util
, it gets converted to java.util.*
.
Where to find that setting to change it?
Open Settings from File-> Settings in Android Studio (ctrl+alt+s).
Go to Editor -> Code Style -> Java/Kotlin and open imports tab then change that N number to any of your suitable case.
There are other options available as well.