tag:blogger.com,1999:blog-694855878384792308.post5106941657541975574..comments2024-03-21T06:26:49.387-07:00Comments on Java67: Difference between Comparator and Comparable in Java - Interview Questionjavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-694855878384792308.post-17584368213187623042015-07-11T01:09:42.745-07:002015-07-11T01:09:42.745-07:00@Anonymous, thanks for pointing this out, correct ...@Anonymous, thanks for pointing this out, correct it now. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-35198027550807348202015-07-11T01:04:12.124-07:002015-07-11T01:04:12.124-07:00@Narendra, thanks. The article is written from int...@Narendra, thanks. The article is written from interview point of view but knowing the difference between them, also help you to decide when to use Comparator over Comparable or vice-versa.javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-83180721732969395002015-07-11T00:54:46.365-07:002015-07-11T00:54:46.365-07:00Really good for interview point of view..👍 Really good for interview point of view..👍 Narendrahttps://www.blogger.com/profile/09478702499427630792noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-54360573574492354102015-04-22T06:04:08.418-07:002015-04-22T06:04:08.418-07:00I think you switched the two terms (Comparator vs ...I think you switched the two terms (Comparator vs Comparable) in the 3rd paragraph, <br /><br />"3. Continuing from previous difference between Comparator vs Comparable, former is used to compare current object, represented by this keyword, with another object, while Comparator compares two arbitrary object passed to compare() method in Java." <br /><br /> Because the word "former" should mean the first item (so here Comparator), but in reality, you meant "Comparable". So maybe it's better to write "Comparable vs Comparator", or use the word "latter" instead of "former". <br /><br /> Anyway, thank you very much for this article!<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-14532447993131717782014-10-10T05:35:16.527-07:002014-10-10T05:35:16.527-07:00Like we can have multiple comparators why cant we ...Like we can have multiple comparators why cant we have multiple compareTo functions by making them in static nested classes??Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-28194301030618226802014-03-10T01:14:42.851-07:002014-03-10T01:14:42.851-07:00Very neat and clear explanation. Thank you so much...Very neat and clear explanation. Thank you so much for the great Knowledge shareAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-5842410377892526912013-08-13T02:33:34.333-07:002013-08-13T02:33:34.333-07:00Use Comparable to provide default ordering and Use...Use Comparable to provide default ordering and Use Comparator to provide custom ordering, as simple as that.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-45953703052079725482013-08-11T11:47:05.054-07:002013-08-11T11:47:05.054-07:00Nice 1,It really good explainationNice 1,It really good explainationAnonymousnoreply@blogger.com