r/learnjava • u/Sonu_64 • Nov 29 '25
Can someone Please Help me understand INTERFACES and exactly why need them?
I get the point of Multiple Inheritance but not the "WHY" behind achieving 100% Abstraction for the methods. Confused in Tight and Loose Coupling as well. Sometimes I feel I understand, the next moment again confused :) I need this information because I have started LLD, LLD needs Abstraction ... I know all of OOP Concepts of Java but interfaces always confuse me.
Thank you.
32
Upvotes
View all comments
Show parent comment
3
u/code_tutor Nov 30 '25 edited Nov 30 '25
Yes, I think you get it.
And someone else's code will call those implemented methods.
The code for insertion sort, merge sort, etc is not going to change. But the data does change, like how to order a String by it's characters or order people in a phone book Contact objects by last+first name, or how to order ComplexNumber objects by their real then imaginary part.
It makes it more flexible. So now you don't need separate sort functions for every type of object. You only need separate Comparable code, which is a much smaller task. It's a lot easier to write the code that says "if this is bigger than that", instead of having to write the entire sorting code as well.