首页 > 编程语言 >JAVA-JavaBean类

JAVA-JavaBean类

时间:2022-11-13 16:44:46浏览次数:46  
标签:JAVA name age public Student s1 JavaBean String

image
image

package com.itheima03;

public class Student {
    private String name;
    private int age;

    public Student(){};

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

    public String getName() {
        return name;

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

    }
    public int getAge(){
        return age;
    }

}

代码2

package com.itheima03;

public class StudentDemo {
    public static void main(String[] args) {
        Student s1=new Student();

        s1.setName("林青霞");
        s1.setAge(30);
        System.out.println(s1.getName()+","+s1.getAge());

    }
}

执行结果

林青霞,30

Process finished with exit code 0

标签:JAVA,name,age,public,Student,s1,JavaBean,String
From: https://www.cnblogs.com/cy-xt/p/16886253.html

相关文章