创建Student类的对象,并为相应属性赋值,并打印输出各属性值。
class Student{
private long studentId;
private int classId;
private int age;
private String studentName;
public long getStudentId(){
return studentId;
}
public void setStudentId(long studentId){
this.studentId=studentId;
}
public int getClassId(){
return classId;
}
public void setClassId(int classId){
this.classId=classId;
}
public int getAge(){
return age;
}
public void setAge(int age){
this.age=age;
}
public String getStudentName(){
return studentName;
}
public void setStudentName(String studentName){
this.studentName=studentName;
}
public void read(){
System.out.println("大家好,我是"+studentName+",学号是"+studentId+",来自软工"+classId+"班,今年"+age+"岁,很高兴认识大家!");
}
}
public class Student_Example1 {
public static void main(String[] args){
Student stu=new Student();
stu.setStudentId(2088999977771L);
stu.setClassId(02);
stu.setAge(22);
stu.setStudentName("张小明");
stu.read();
}
}