首页 > 其他分享 >PersonTest

PersonTest

时间:2024-09-23 14:22:47浏览次数:11  
标签:p1 String age PersonTest Person void name


package com.shrimpking.t6;


/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Shrimpking
 * @create 2024/9/16 12:00
 */
class Person{
    String name;
    int age;

    void talk(){
        System.out.printf("我是%s,今年%d岁",this.name,this.age);
    }

   void setName(String name){
        this.name = name;
    }

   void setAge(int age){
        this.age = age;
    }
}

public class PersonTest
{
    public static void main(String[] args)
    {
        Person p1 = new Person();
        p1.setName("zhang");
        p1.setAge(32);
        p1.talk();
    }
}

标签:p1,String,age,PersonTest,Person,void,name
From: https://blog.51cto.com/u_15356972/12089177

相关文章