巴扎黑2017-04-17 13:08:18
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.
巴扎黑2017-04-17 13:08:18
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.
PHP中文网2017-04-17 13:08:18
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.
class O{
int i;
Integer j;
}