package top.hyself; public class Test_1023 { private int id; private String name; private int sex; private int age; private String city; public Test_1023(int id,String name,int sex,int age,String city) { this.id = id; this.name = name; this.sex = sex; this.age = age; this.city = city; } public int getId() { return id; } public void setId(int a) { this.id = a; } public String getName() { return name; } public void setName(String a) { this.name = a; } public int getSex() { return sex; } public void setSex(int a) { this.sex = a; } public int getAge() { return age; } public void setAge(int a) { this.age = a; } public String getCity() { return city; } public void setCity(String a) { this.city = a; } }
package top.hyself; public class Birth { public static void main(String[] args) { Test_1023 human1 = new Test_1023(100001,"Fitz",1,26,"北京"); Test_1023 human2 = new Test_1023(100002,"Simmons",0,25,"北京"); Test_1023 human3 = new Test_1023(100003,"Ward",1,28,"天津"); Test_1023 human4 = new Test_1023(100004,"Daisy",0,21,"上海"); print(human1);print(human2);print(human3);print(human4); } public static void print(Test_1023 x) { // TODO Auto-generated method stub String sex; if(x.getSex() == 1) sex = "男"; else sex = "女"; System.out.println("id:" + x.getId() +",name:" + x.getName() + ",sex:" + sex + ",age:" + x.getAge() + ",city:" + x.getCity()); } }