I am new to java (basically I am a C#.Net guy). I extracted the java.util.Comparator interface. There I can see two abstract methods (1) public abstract int compare(java.lang.Object arg0, java.lang.Object arg1); and (2) public abstract boolean equals(java.lang.Object arg0);. I implemented this interface in MyClass and it is working fine.
My Question is:
By normal OOPs rule, we should define all the abstract methods which are available in interface at the time of implementation.
But here we have 2 abstract methods (compare and equals) and I am implementing only campare method. I just ignored the equals methods. But I am not getting any compilation or run-time error.
At the same time, if I not implement the method compare, I am getting compilation error.
What is the difference between the abstract methods compare and equals? Why "compare" method only mandatory? Please explain to me