java notes

上一篇 / 下一篇  2007-12-19 11:32:49

Inheritance:A is a B relationship.

polymorphism:When you send a message to an object, the object will do the right
thing, even when upcasting is involved.

Sample:

void doStuff(Shape s) {
s.erase();
// ...
s.draw();
}

Circle c = new Circle();
Triangle t = new Triangle();
Line l = new Line();
doStuff(c);
doStuff(l);doStuff(t);

 


TAG:

 

评分:0

我来说两句

我的栏目

日历

« 2024-04-02  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 8794
  • 日志数: 15
  • 建立时间: 2007-08-27
  • 更新时间: 2008-01-07

RSS订阅

Open Toolbar