X Tutup
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Item 61: Prefer privmite types to boxed primitives

Key Points

  • Applying the == operator to boxed primitives is almost always wrong, because the == operator is an identity comparison, i.e. for objects, the == operator compares the memory addresses of the objects.
  • Avoid unnecessary autoboxing, i.e. unnecessary object creations.
    • e.g. Long sum = 0L; sum += 1; will auto-unbox sum, then autobox the incremented value into a new Long object; instead, use long sum to avoid unnecessary autoboxing.

Issue

X Tutup