Should use valueOf instead of new
Should use valueOf
instead of new
You should not call the constructor for wrapper classes directly, such as`new Integer(42)`. Instead, call the valueOf
factory method, such as Integer.valueOf(42)
. This will typically use less memory because common integers such as 0 and 1 will share a single instance.
Issue id: UseValueOf
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for Android 2023.3, Qodana for JVM 2023.3 |
Plugin: | Android, 2022.3.1 Beta 2 |
Last modified: 13 July 2023