How do java Integer and int compare content values to see if they are equal?

before I didn"t ask clearly, my entanglement point is more convenient to judge how to be equal to two Integer objects, because the former needs to judge null,

.
Integer a = null;
Integer b = new Integer(128);
System.out.print(Objects.equals(a,b));//null
Mar.22,2021

Integer caches numbers between-128and 127. if you are out of range, you can only new new objects .
is generally not recommended to use = , because two-class comparison is whether the object is the same address.
generally uses the equals () method, and equals compares the content.

clipboard.png

clipboard.png


use the equals (Object) method to compare objects.


:<br>"Integer-128~127int==false"

int = 128 int = 127==true

    public static void main(String[] args) {
        int a = 127;
        Integer i = new Integer(127);

        System.out.println(a == i);

        int b = 128;
        i = new Integer(128);

        System.out.println(b == i);
    }

for the question of whether the second Integer object is empty, refer to the implementation of Integer.equals to determine the null first, and then execute the judgment condition.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ed28ba-33e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ed28ba-33e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?