- class Person
- {
- public int age;
- public void eat()
- {
- System.out.println("Eatinh...");
- }
- public void sleep()
- {
- System.out.println("Sleeping...");
- }
- }
- public class Earth
- {
- public static void main(String[] args)
- {
- Person person1 = new Person();
- Person person2;
- person2 = new Person();
- person1.age = 18;
- System.out.println("person1:" + person1.age);
- System.out.println("person2:" + person2.age);
- person1.eat();
- person2.sleep();
- }
- }
来源: http://www.bubuko.com/infodetail-3361426.html