![]() ![]() This is the comparison between int and int, which turns into the comparison of values When Integer = int judges, it will unpack the inger and convert it to the basic data type. =The essence of is memory address comparison In short, Integer.equals Is a value comparison, a comparison between int and int The source code of this method is very simple, which is to return the basic data type in this object To explore the reasons, the following is Integer.equals Source code ![]() It can be found that the equals comparison is true. Basic data typeĭo a simple experiment, output a variety of cases of packing and unpacking results int i1 = 132 Precision is lost from large to small: casts must be used when converting a large capacity type to a small capacity type. You cannot convert an object type to an object of an unrelated class. Similarly, if the number of bits of the float data type is 32, it can be automatically converted to the 64 bit double type.īyte,short,char-> int -> long-> float -> doubleĭata type conversion must meet the following rules: The number of bits in the data type before conversion is lower than that in the data type after conversion.įor example, if the bit number of the short data type is 16 bits, the int type with 32 bits can be automatically converted. Therefore, java provides eight basic data types, which are stored in the stack. For the data types we often operate on, creating an object each time consumes too much resources. Because in java, a new object is stored in the heap. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |