tag:blogger.com,1999:blog-8712770457197348465.post4941028523796286017..comments2024-03-19T01:04:48.783-07:00Comments on Javarevisited: Avoid Using "==" instead of equals() to compare Objects in Java? Examplejavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-8712770457197348465.post-85501934467789784952016-05-28T04:08:01.890-07:002016-05-28T04:08:01.890-07:00@Gupta, yes you are right, it's individual cla...@Gupta, yes you are right, it's individual class' responsibility to define the equality. So, if you create a domain object, you must provide equals(), hashcode() and compareTo(). They are very useful, also equals() and compareTo() should return 1 for equal objects.javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-88516050343260029252016-05-26T06:33:23.846-07:002016-05-26T06:33:23.846-07:00Good Information. One point to add here that for O...Good Information. One point to add here that for Object class, equals method implementation is same as comparing "==" and leftover to its sub-class (String, Integer or any class) to define how would it like to be compared to be equal (For String its exact unicode char and for Integer its the number comparison).Guptahttp://singletonjava.blogspot.comnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-1149325802409432582016-05-22T16:21:25.335-07:002016-05-22T16:21:25.335-07:00I do like this serie, and would like to see more p...I do like this serie, and would like to see more posts on common java mistakes. DrMabullehttps://www.blogger.com/profile/07097962890746867191noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-46661681577305475742016-05-21T06:08:31.821-07:002016-05-21T06:08:31.821-07:00@Mutturaj, good catch, thanks for pointing it out....@Mutturaj, good catch, thanks for pointing it out. I agree it should be -128 to 127, the range of byte in Java. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-13926708748052131722016-05-21T01:52:57.030-07:002016-05-21T01:52:57.030-07:00Very nice explanation...
One small correction In t...Very nice explanation...<br />One small correction In the program its mentioned as "outside -128 to 128 are equal using =="<br />Please correct the positive range to 127Anonymoushttps://www.blogger.com/profile/17051727184585928752noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-55947523581042535872016-03-26T08:42:09.813-07:002016-03-26T08:42:09.813-07:00Good InformationGood InformationPratikhttps://www.blogger.com/profile/04317066707940313485noreply@blogger.com