day09-继承中方法的覆盖重写_应用场景

This commit is contained in:
2026-01-22 15:01:14 +08:00
parent 0fedea922d
commit e4c13af21b
3 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
package com.inmind.extends_override03.test;
/*
重写的应用场景:手机
重写的意义:对于父类中方法的功能的扩展
*/
public class Demo04 {
public static void main(String[] args) {
//买新旧手机,感受下重写的效果
Phone phone = new Phone();
phone.show();
System.out.println("-------");
NewPhone newPhone = new NewPhone();
newPhone.show();
}
}