日期:2014-05-20 浏览次数:20766 次
public class TestString {
public static void main(String[] args) {
Point p1 = new Point();
Point p2 = new ColorPoint();
ColorPoint p3 = new ColorPoint();
p1.draw(p1);
p1.draw(p2);
p2.draw(p3);
p2.draw(p1);
p2.draw(p2);
p2.draw(p3);
}
}
class Point {
public void draw(Point p) {
System.out.println("Draw in Point");
}
}
class ColorPoint extends Point {
public void draw(ColorPoint p) {
System.out.println("Draw in ColorPoint");
}
}
}