Is There Any Good Reason to Use Abstract Class with New Additions to Interfaces in Java 9?

Viewed 339

Since Java 9 release is there any good reason to use abstract classes anymore? Seems like you can do everything with interfaces from now, plus you can have multiply inheritance with interfaces.

Java SE 9: Interfaces

  • Constant variables
  • Abstract methods
  • Default methods
  • Static methods
  • Private methods
  • Private Static methods

Am I missing something? Can't find any good reason except, probably, backward compatibility.

1 Answers

Indeed, you're missing something:

  • non-constant variables
  • protected and package-private methods

In general, you don't have to use a feature just because you can. In particular, be careful with multiple inheritance. It can make things complicated very quickly.

Related