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.
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.
In many cases, only Integer can be used, such as List<Integer>.
Use int for temporary variables, such as for(int i=0;;)
is aligned with other variables. If you see the following code, you will vomit blood.