What's the difference between the implements & extends keywords in Java

sachin picture sachin · Feb 29, 2012 · Viewed 60.6k times · Source

What's the difference between the following keywords in Java: implements, extends?

Answer

blahman picture blahman · Feb 29, 2012

An interface is an abstract specification of how a class should behave whilst a class is a concrete implementation of such a specification.

Therefore, when you write implements you're saying that you are fulfilling some abstract specification in the implementation you've written.

extends means that you take either an implementation (class) or specification (interface) and add to it with different or new functionality (or change the specification of its behaviour), thus modifying its behaviour and extend-ing it.