- 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.- e.g. sample code
- Avoid unnecessary autoboxing, i.e. unnecessary object creations.
- e.g.
Long sum = 0L; sum += 1;will auto-unboxsum, then autobox the incremented value into a newLongobject; instead, uselong sumto avoid unnecessary autoboxing.
- e.g.
item61
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||