- class person
- {
- private int age;
- public void setAge(int a)
- {
- age = a;
- }
- public int getAge()
- {
- return age;
- }
- void speak()
- {
- System.out.println("age="+age);
- }
- }
- class PersonDemo
- {
- public static void main(String[] args)
- { person p =new person();
- p.setAge(20);
- p.speak();
- }
- }
复制代码 |
|