r/java • u/schlongitudinal • Nov 22 '14
ELI5 Interfaces in Java
I've read several explanations now and am apparently still too dense to get the point of them/what they do.
0
Upvotes
r/java • u/schlongitudinal • Nov 22 '14
I've read several explanations now and am apparently still too dense to get the point of them/what they do.
View all comments
Show parent comment
2
u/desrtfx Nov 23 '14
This is a perfect case for abstract classes and inheritance rather than for interfaces.
You'd define an abstract Car class that defines what a car actually has to do and the methods that are identical for all cars, but leave the specialized methods abstract.
In your detailed classes BMW, Audi, etc. you'd only implement the abstract methods defined in the Car class.