package com.chuoji; public class People { private String name; private int age; private String sex; private double height; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public double getHeight() { return height; } public void setHeight(double height) { this.height = height; } public String getsay() { return "你好"; } public int getAccount(int a, int b) { return a+b; } }
package com.chuoji; public class Text04 { public static void main(String[] args) { People p=new People(); p.setName("张三"); p.setAge(18); p.setSex("男"); p.setHeight(1.80); System.out.println("姓名:"+p.getName()); System.out.println("年龄:"+p.getAge()); System.out.println("性别:"+p.getSex()); System.out.println("身高:"+p.getHeight()); System.out.println("他说:"+p.getsay()); System.out.println("23+45="+p.getAccount(23, 45)); p.setName("李四"); System.out.println("姓名改为:"+p.getName()); } }