JAVA基础教程4.pptVIP

  • 7
  • 0
  • 约4.73千字
  • 约 20页
  • 2015-08-14 发布于广东
  • 举报
Reusing classes 华南理工大学 计算机科学与工程学院 韦佳 csjwei@scut.edu.cn Composition syntax Simply place object references inside new classes. //SprinklerSystem.java Reference initialization. //Bath.java At the point the objects are defined; In the constructor for that class; Right before you actually need to use the object. (lazy initialization) Using instance initialization. Inheritance syntax extends keyword. //Detergent.java “this new class is like that old class.” You automatically get all the fields and methods in the base class. super keyword. Refers to the “superclass” that the current class inherits.

文档评论(0)

1亿VIP精品文档

相关文档