package stu;
class student {
//成员变量
private String no;
private String name;
private int age;
private String address;
//构造成员方法
public student() {
}//无参
public student(String no, String name, int age, String address) {//有参
this.no = no;
this.name = name;
this.age = age;
this.address = address;
}
//输入输出成员属性
public String getNo() {
return no;
}
public void setNo(int no) {
this.no = String.valueOf(no);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
public class students{
public static void main(String[] args){
student st=new student();//创建对象
st.setNo(80);
st.setName("小花");
st.setAge (20);
st.setAddress("成都");
System.out.println("学号:"+st.getNo()+"名字:"+st.getName()+"年龄:"+st.getAge()+"地址:"+st.getAddress());//打印信息
System.out.println(st);
}
}
学生基本信息管理
最新推荐文章于 2024-09-15 19:46:31 发布