tag:blogger.com,1999:blog-8712770457197348465.post2410612869053215778..comments2024-03-17T23:01:26.872-07:00Comments on Javarevisited: Why Avoid Comparing Integers in Java using == Operator? Examplejavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-8712770457197348465.post-23511902719928867452022-12-13T02:40:51.962-08:002022-12-13T02:40:51.962-08:00I think equal will take Integer object if you want...I think equal will take Integer object if you want to compare Integer value. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-48028892381700441612022-12-12T06:17:13.946-08:002022-12-12T06:17:13.946-08:00It's seem that it when comparing two integer ...It's seem that it when comparing two integer value using .equals .....it take it as string so,that both integer will be compared with no limitation and give out correct output but as String ... :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-83790818880284162322021-08-30T22:29:44.984-07:002021-08-30T22:29:44.984-07:00thanks it is very helpful to me
thanks it is very helpful to me<br />Anonymoushttps://www.blogger.com/profile/02574156635895605698noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-73109724402737760522021-07-22T21:08:49.134-07:002021-07-22T21:08:49.134-07:00I found myself asking the question what is the pur...I found myself asking the question what is the purpose of this article. == compares the actual object & not it's stateJoseph McCayhttps://www.blogger.com/profile/18136889155232073379noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-26206875565819572592020-11-04T00:25:53.531-08:002020-11-04T00:25:53.531-08:00Hello Dakshit, glad you find information useful. Hello Dakshit, glad you find information useful. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-5275680567911195412020-11-03T18:17:50.819-08:002020-11-03T18:17:50.819-08:00very helpfullvery helpfulldakshithttps://www.blogger.com/profile/15248483422403113962noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-13201765218974116032011-02-24T19:35:49.693-08:002011-02-24T19:35:49.693-08:00@Glamdring , thanks for answering @Anonymous (2nd)...@Glamdring , thanks for answering @Anonymous (2nd) and making it clear not to use `==` for objects.Javin @ FIX Protocol Tutorialshttp://javarevisited.blogspot.comnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-28029409613834876422011-02-24T19:34:18.885-08:002011-02-24T19:34:18.885-08:00Hi Anonymous thanks for sharing VM-Param -XX:AutoB...Hi Anonymous thanks for sharing VM-Param -XX:AutoBoxCacheMax=X to us. I think valueOf is also work on same principle and return same object until a limit most likely in the range of byte -127 to 128 and return different object outside the range.Javin @ FIX Protocol Tutorialshttp://javarevisited.blogspot.comnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-52164936513136580262011-02-20T07:16:28.526-08:002011-02-20T07:16:28.526-08:00I never use autoboxing. I use Integer.valueOf inst...I never use autoboxing. I use Integer.valueOf instead, so it is clear, that I am working with objects. You can configure eclipse to mark autoboxing as error.<br /><br />Btw. You can configure the cache-max-value by the VM-Param -XX:AutoBoxCacheMax=X. The value 127 is default.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-74394506190079832792011-02-19T23:31:45.996-08:002011-02-19T23:31:45.996-08:00@Anonymous (2nd) you are wrong. The practice is to...@Anonymous (2nd) you are wrong. The practice is to never use `==` for objects. It's used only for primitives. So no confusion there.Glamdringhttps://www.blogger.com/profile/15991712631380325703noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-70499987027597773042011-02-19T16:20:42.723-08:002011-02-19T16:20:42.723-08:00It doesn't really have anything to do with &qu...It doesn't really have anything to do with "recommended practice". That is the very definition of "==" and "equals".kaqqaohttps://www.blogger.com/profile/05515187432098285483noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-38724366887860676372011-02-19T15:40:30.284-08:002011-02-19T15:40:30.284-08:00Yet another reason why I think this language is a ...Yet another reason why I think this language is a dead end - the people responsible for the language design are simply nuts. It's rather unwise to make certain elements of the language behave differently depending on the level of optimization.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-91148926223260956882011-02-18T09:38:29.441-08:002011-02-18T09:38:29.441-08:00In order to avoid surprise, I think it's bette...In order to avoid surprise, I think it's better to always think of "==" in term of "same object" instead of "equals"Anonymousnoreply@blogger.com