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