r/learnjava • u/uniqueUsername_1024 • Dec 22 '25
What is the semantic difference between an interface and an abstract class?
I understand the mechanics—interfaces support multiple inheritance, abstract classes can declare instance variables and override Object methods, etc. However, I don't understand what it means to call something one or the other, especially because default methods exist.
In short: if I declare abstract class Foo, what am I saying about the nature of all Foos? Critically, how does that change if I declare interface Foo instead?
42
Upvotes
View all comments
Show parent comment
1
u/Kikok02 Dec 22 '25
Stack and Vector came out first, Collection came out later to improve but still taking backward compatibility into account.
Collection API != Collections API.
You can inherit from the Collection API interfaces and implement your DS as you wish. The goal was extending your custom made DS with minimal overhead whilst also minding backward compatilibity, and it was successful at that.
Talking performance is relative to the context. I could use C and implement my own DS for max performance, but that would sacrifice developer productivity and be prone to errors, I could also use CPython to make my life easier and still get those C structures under the hood, maybe I want JS/TS for team work taking care of an on going project. Theses choices depend on context.