How to judge whether two Long type data are equal

@Test
public void test1Long() {
Long a=(long) 19257;
Long b=(long) 19257;
System.err.println("The result of a==b is "+(a==b));
System. err.println("a.longValue()==b.longValue() results in "+(a.longValue()==b.longValue()));

}

The result of running the above program is:

                The result of a==b is false

                The result of a.longValue()==b.longValue() is true


reason:

== in primitive data types compares the value of two primitive data types for equality
 == In the reference data type, the comparison is whether the referenced objects are equal, that is, whether the same object is referenced, and the comparison is the address


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325675065&siteId=291194637