3 ms·
So at Java 8 they added the ability for interfaces to have default implementations - this was so that the collections API (among others) could be expanded with
by aardvark179 9y ago
So at Java 8 they added the ability for interfaces to have default implementations - this was so that the collections API (among others) could be expanded with lots of support for the new lambda features without breaking compatibility.
Allowing private methods means default implementations can be easily refactored to move common code to private methods without those internal methods themselves becoming part of the interface. Yes Java does have abstract types, but multiple inheritance is allowed from interfaces (which aren't structural) but not abstract types so interfaces are very widely implemented across the standard and other libraries.
- pwaivers 9y agoI did not realize that Java had implementations in interfaces already. This makes perfect sense why they would add the private method then. Thanks for answer!