deepak kushwaha wrote:comparator interface dont have any equal method!!!
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
It's "equals(java.lang.Object)" not "equals", and yes it does. Here it is.deepak kushwaha wrote:comparator interface dont have any equal method!!!
It is not essential to override the java.util.Comparator#equals(java.lang.Object) method, unless you need to confirm identicality of two Comparators
Anand Sivathanu wrote:
we already know that Comparator is an interface,so we must override all methods present in an interface.
without override equals() how it work?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
deepak kushwaha wrote:actually you are comparing strings and string by default have implemented equals method. if you were comparing two objects then you need to override this method
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
All the methods present in interface must be overridden by the implementing class.
Anand Sivathanu wrote:i know that equals() method is in Object class.
comparator also has equals() method,which is needed to be overriden.
All the methods present in interface must be overridden by the implementing class.
this is the rule in java,if i am not wrong.
coming back to point,
I have overrided only the compare().
I have not override the equals().
I have not overrided all the methods present in comparator interface.
how it works?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Anand Sivathanu wrote:
All the methods present in interface must be overridden by the implementing class.
this is the rule in java,if i am not wrong.
Abimaran Kugathasan wrote: . . . the link! In that they clearly mentioned it!
Campbell Ritchie wrote:
Abimaran Kugathasan wrote: . . . the link! In that they clearly mentioned it!
I see you have actually read the link
And Mike Simmons has explained it too.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Campbell Ritchie wrote:I see you have actually read the link
And Mike Simmons has explained it too.
Gobi Shanmugam wrote:If you can't understand please consider below thought.
1. class C implements interface A and interface B.
2. Both interfaces A and B have same method like doPrint()
Now the question is class C override doPrint() method of A or B ?
Thank you my well lotioned goddess! Here, have my favorite tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|