Skip to content

Latest commit

 

History

History
14 lines (11 loc) · 318 Bytes

ShortInstantiation.md

File metadata and controls

14 lines (11 loc) · 318 Bytes

ShortInstantiation

Category: pmd
Rule Key: pmd:ShortInstantiation


In JDK 1.5, calling new Short() causes memory allocation. Short.valueOf() is more memory friendly. Example :

public class Foo {
private Short i = new Short(0); // change to Short i =
Short.valueOf(0);
}