java 类型是直接使用基本类型还是就干脆直接用java.lang的类型
黄舟
黄舟 2017-04-17 13:06:18
0
14
1122

比如:

Integer => int
Boolean => boolean
...

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(14)
Ty80

Divide into different scenes

巴扎黑

jdk 1.5. There is an automatic unboxing and packing mechanism. The purpose is to cater to the core idea of ​​​​Java, everything is an object.
Therefore, during development, if the performance requirements are not very high, it is recommended to use the packaging class in the java.lang package.

巴扎黑

Depends on the specific needs, but I personally always give priority to using basic types, because they take up less space. Compared with packaging types, their construction speed is also faster. Compared with packaging types, they are objects. , Secondly, the packaging classes provide static methods that can construct the packaging type from the basic type, so if you need to use the packaging type again, just convert it immediately.

洪涛
  1. In many cases, only Integer can be used, such as List<Integer>.

  2. Use int for temporary variables, such as for(int i=0;;)

  3. is aligned with other variables. If you see the following code, you will vomit blood.

class O{
    int i;
    Integer j;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template