“构造方法是定义在JAVA类中的一个用来初始化对象的方法”个人感觉老师把这个说得太口语化了,有点绕口。听了三遍,自己改了两次demo,才明白过来意思。
2015-12-03
public static void main(String[] args) {
Traffic tfc1 = new Bus(); //父类引用指向公交子类对象
Traffic tfc2 = new Ship();//父类引用指向轮船子类对象
Traffic tfc3 = new Plane();//父类引用指向飞机子类对象
Traffic tfc4 = new Train();//父类引用指向火车子类对象
Traffic tfc5 = new Taxi();//父类引用指向出租车子类对象
}
Traffic tfc1 = new Bus(); //父类引用指向公交子类对象
Traffic tfc2 = new Ship();//父类引用指向轮船子类对象
Traffic tfc3 = new Plane();//父类引用指向飞机子类对象
Traffic tfc4 = new Train();//父类引用指向火车子类对象
Traffic tfc5 = new Taxi();//父类引用指向出租车子类对象
}
2015-12-03
static String className = "JAVA开发一班";
public static void main(String[] args) {
System.out.println(HelloWorld.className);
HelloWorld hi=new HelloWorld();
System.out.println(hi.className);
hi.className="JAVA开发二班";
System.out.println(HelloWorld.className);
}
public static void main(String[] args) {
System.out.println(HelloWorld.className);
HelloWorld hi=new HelloWorld();
System.out.println(hi.className);
hi.className="JAVA开发二班";
System.out.println(HelloWorld.className);
}
2015-12-02