java - bean 用引用类型好还是用基本类型?
PHP中文网
PHP中文网 2017-04-17 17:47:08
0
2
390

两者有什么判别的标准在什么情况下使用基本类型,还是使用引用类型?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
刘奇

Generally speaking, basic types are preferred. In the following two situations, reference types are preferred

  1. POJO object corresponding to the database table

  2. 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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!