重写显示部分。。。是怎么回事
Car里面父类的代码:
package demo2;
public class Car {
public int model;
public String Pattern;
public String Type;
public void fun(){
System.out.println("车是让人类坐的");
}
}
Bus中子类的代码:
package demo2;
public class Bus extends Car {
public void fun(){
System.out.println("bus是让人类坐的");
}
}
测试代码:
package demo2;
public class BusIntail {
public static void main(String[] args) {
// TODO Auto-generated method stub
Bus bus=new Bus();
bus.model=0122;
bus.Pattern="宝马";
bus.fun();
}
}
为什么我的代码只能运行处:bus是让人类坐的。然而:
bus.model=0122;
bus.Pattern="宝马";
不显示呢!