解决方法
这是Java Notes在
autoboxing上说的:
Prefer primitive types
Use the primitive types where there is no need for objects for two
reasons.
- Primitive types may be a lot faster than the corresponding wrapper
types,and are never slower.- The immutability (can’t be changed after creation) of the wrapper
types may make their use impossible.- There can be some unexpected behavior involving == (compare references) and .equals() (compare values). See the reference below for examples.