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: