publicclassPerson{
String name;int age;publicPerson(String name,int age){
this.name = name;this.age = age;}publicvoidsayHello(){
System.out.println("Hello, my name is "+ name);}}// 创建对象Person person =newPerson("Alice",25);
person.sayHello();// 输出: Hello, my name is Alice