再写一个测试类
public class TestClass { public static void main(String[] args) { // 创建一个Person对象 Person person = new Person("John", 25);
// 调用Person类的方法
person.sayHello();
person.growOlder();
// 输出Person对象的信息
System.out.println("Name: " + person.getName());
System.out.println("Age: " + person.getAge());
}
}
原文地址: https://www.cveoy.top/t/topic/hPxn 著作权归作者所有。请勿转载和采集!