1 package com.wy; 2 3 public class June$9 { 4 public int id; 5 public String name; 6 public int age; 7 public String city; 8 public String introduce() { 9 return "My id=" + id + ", name=" + name + ", age=" + age + ", city=" + city ; 10 } 11 //构造方法 12 public June$9() { 13 14 } 15 //有参数构造 16 public June$9(int id,String name,int age,String city) { 17 this.id=id; 18 this.name=name; 19 this.age=age; 20 this.city=city; 21 } 22 23 }
1 package com.wy; 2 3 public class DemoPerson { 4 5 public static void main(String[] args) { 6 // TODO Auto-generated method stub 7 June$9 p1=new June$9(); 8 June$9 p2=new June$9(); 9 June$9 p3=new June$9(); 10 June$9 p4=new June$9(); 11 p1.id=110001; 12 p1.name="刘备"; 13 p1.age=43; 14 p1.city="蜀国"; 15 p2.id=110002; 16 p2.name="关羽"; 17 p2.age=35; 18 p2.city="蜀国"; 19 p3.id=110003; 20 p3.name="张飞"; 21 p3.age=32; 22 p3.city="蜀国"; 23 p4.id=110004; 24 p4.name="诸葛亮"; 25 p4.age=25; 26 p4.city="蜀国"; 27 System.out.println(p1.introduce()); 28 System.out.println(p2.introduce()); 29 System.out.println(p3.introduce()); 30 System.out.println(p4.introduce()); 31 32 } 33 34 }