抽象类是指用abstract关键字修饰的类,这种类是为了定义一个模板,真正的实现要让它的子类去负责,下面例子中,我们定义一个抽象类Person类,Person类具有属性 name,age,能够说话say(); 但具体说什么内容则由子类去实现: 定义具体的子类,学生类Student和工人类Worker,学生类中添加一个分数score属性,工人类中添加了工资salary属性 主方法中声明Person类,但用具体的子类去实例化(new Student或者new Worker),这样一来调用方法的时候,就会去调用具体子类自己覆写过的方法,其中包含了Java多态性的意思. $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('
    ').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); }); window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "1", "bdMiniList": false, "bdPic": "", "bdStyle": "0", "bdSize": "16" }, "share": {} }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];