Article DetailsJava - implement or extend? |
| Date Added: June 02, 2009 02:38:51 PM |
| Author: AbleShare |
| Category: |
| "implements" is for interfaces
; "extends" is for classes. You implement interfaces and you extend classes. You can only extend one class in java, but you can implement many interfaces. When you "extend" a class, any methods that you write with the same name will override the parent class' method. When you "implement" a class, the parent class had nothing more than the method definition (i.e. there was no code in the method) so, in effect, all you are doing is adding your own method code to what was just a method declaration and therefore not overriding the parent methods. |