package com_black.jicheng; //手机类 public class phone { public void call(String name){ System.out.println("给"+name+"打电话"); } } package com_black.jicheng; public class phone01 extends phone{ @Override//注解 可以帮助我们检查方法重写的正确性 public void call(String name){ System.out.println("开启视频功能"); //System.out.println("给"+name+"打电话"); super.call(name); } } //注意:父类中私有方法不能被重写 //子类方法访问权限不能比父类低(public>默认>私有) package com_black.jicheng; public class phoneDemo { public static void main(String[] args) { phone p=new phone(); p.call("胡女士"); System.out.println("----------"); phone01 c=new phone01(); c.call("胡女士"); } }
标签:name,新人,System,笔记,phone,call,重写,public,out From: https://www.cnblogs.com/hxh-/p/17692273.html