1, basic type and basic type of package for the "= =" operator comparison, the basic package type will automatically remove the box into the basic type and then compare, so the integer (0) will automatically unboxing to the int type and then compare, obviously return true;
2, two integer type "= =" comparison, if its value is 128 to 127, then return True, otherwise return false, this is related to the buffer object of integer.valueof (), here does not repeat.
3, two basic type of package for equals () comparison, first equals () will compare the type, if the type is the same, continue to compare the value, if the value is the same, return True
4, the basic package type calls Equals (), but the parameter is the basic type, this time, the first automatic boxing, the basic type conversion to its package type, and then the comparison in 3.
int A=257;integer B=257;integer C=257;integer b2=57;integer c2=57; System.out.println (a==b);//true//system.out.println (A.equals (b)); Compile error, basic type cannot call Equals () System.out.println (B.equals (257.0));//flasesystem.out.println (b==c);// FalseSystem.out.println (B2==C2);//true
Java basic type and package type