Three reasons why wrapper classes should not be used in Java

I've been doing it somehow until now, but when I specified the variables, I finally found out the difference in the primitive types of the wrapper class, so I'll leave it as a memo.

Reason 1: It seems that the performance of the program deteriorates when using the wrapper class. Reason 2: The wrapper class allows nulls, which can mislead readers of behavior into thinking that "nulls can be entered". Reason 3: Since the wrapper class is one of the objects, if you try to compare the values ​​with the comparison operator as follows, it will be false. スクリーンショット 2021-01-06 21.52.00.png

Also, the wrapper class has the advantage that methods can be used, but since they are static methods, you only have to call them when you want to use the method without using the wrapper class in the variable declaration, so basically the variable declaration There is no problem with primitive types.

Recommended Posts

Three reasons why wrapper classes should not be used in Java
[Java] When var should be used and when it should not be used
Why Java Vector is not used
Map keySet, values should not be used
Why Java String typeclass comparison (==) cannot be used
The story that the variable initialization method called in the Java constructor should not be overridden
The case that @Autowired could not be used in JUnit5
Sftp (JSch wrapper) in Java
About abstract classes in java
Summary of ORM "uroboroSQL" that can be used in enterprise Java
Note that system properties including JAXBContext cannot be used in Java11
Syntax examples often used in Java
[Java] Do not use "+" in append!
How to use classes in Java?
The story that the Servlet could not be loaded in the Java Web application