要给学生们讲卷子,不知道这个转型问题怎么讲,搜了几个例子,才发现这个例子最合适,也好懂。
class Chinese{
public static void print(){
System.out.println("this is 中国人");
}
}
class Guangdongren extends Chinese{
public static void print(){
System.out.println("this is 广东人 ");
}
}
class HunanRen extends Chinese{
public static void print(){
System.out.println("this is 湖南人 ");
}
伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-08/1186901451.html
}
向上转型,向下转型
'http://www.etoow.com/html/2007-08/1186901451.html