`
lhx1026
  • 浏览: 299721 次
  • 性别: Icon_minigender_2
  • 来自: 广州
社区版块
存档分类
最新评论

《Thinking in java》——多态(1)

阅读更多

    If you call a dynamically-bound method inside a constructor, the overridden definition
that method is used. However, the effect of this call can be rather unexpected because th
overridden method will be called before the object is fully constructed. This can conceal
difficult-to-find bugs.

 

    (在子类中)如果你在构造方法中调用动态绑定的方法(父类中有的方法),就会调用到这个方法的重写方法。然而,这种调用的效果是相当不被期望的,因为重写的方法会在对象完全构造之前被调用,这会掩盖掉很难发现的bugs。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics