首页 > 其他 > 详细

abstract class and interface

时间:2016-12-11 10:19:21      阅读:228      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/touchdown/p/6159036.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!