It is recommended not to use basic types, but to use package types. For example, when using int, use Integer, and when using long, use Long, because if your object is to operate on the database, you need to use ORM, and if you use basic types The value when the object is initialized is 0, and the second packaging type is null. ORM will not judge 0 during operation, but it will judge null back, so it is recommended to use the packaging type.
Generally speaking, basic types are preferred. In the following two situations, reference types are preferred
POJO object corresponding to the database table
HTTP Request Form Object
Reference types have more null support than basic types, and of course have more possibilities for NullPointerException
It is recommended not to use basic types, but to use package types. For example, when using int, use Integer, and when using long, use Long, because if your object is to operate on the database, you need to use ORM, and if you use basic types The value when the object is initialized is 0, and the second packaging type is null. ORM will not judge 0 during operation, but it will judge null back, so it is recommended to use the packaging type.