package ch4;/*** 注意:该类中也有方法重载* @author TaoZhang**/public class Person {// 属性(成员变量)定义private int id;private int age = 20;// 方法定义public int getAge() {return age;}public void setAge(int i) {age = i;}public int getID() {return id;}public void info() {System.out.println("Hello, id:" + id);}public void info(String v) {System.out.println(v + ", id:" + id);}// 构造方法定义, 包含重载public Person() {id = 0;//System.out.println("构造方法执行");}public Person(int id, int age) {this.id = id;this.age = age;//System.out.println("Person(int,int)构造方法执行");}public static void main(String[] args) {Person jack = new Person(10, 20);jack.info();Person rose = new Person(11, 22);rose.info("rose");}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。