abstract class and interface
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了abstract class and interface相关的知识,希望对你有一定的参考价值。
Interface separates what a Class does and how does it work. List interface lets different type of List to implement its own method.
interface has more flexibility. A class can implements multiple interfaces but can only extends one class.
once interface is implemented by Class, we can not change interface, otherwise, we will break existing code. so interface is like "contract". For
abstract class, we can still add behavior without breaking existing code.
abstract class allows default implementation. In my project of tweet sentiment analysis, I use Classifier abstract class and in classify_many(), it
has default implementation but leaves any class that extends it to implement their own classify() method.
以上是关于abstract class and interface的主要内容,如果未能解决你的问题,请参考以下文章
Java Interface and Abstraction
java abstraction and encapsulation
‘ActionTracksFragmentToFragmentTrack‘ is not abstract and does not implement abstract member public