public class Person{ public void say(){} } public class Student extends Person{ public void say(){ System.out.println("I am a student"); } } public class Teacher extends Person{ public void say(){ System.out.println("I am a teacher"); } } main: Person s = new Student(); Person t = new Teacher(); s.say(); t.say();
本文来源于:奈学开发者社区
标题:面向对象编程(Object-Oriented Programming, OOP)概述
url:https://ask.naixuejiaoyu.com/article/481
如有侵权,请联系我删除!谢谢~
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。