Design a Student class, including name, gender, age, these three fields and corresponding properties, constructors (contain a parameter, a containing two parameters, a three parameters included), a common function print ()
output information of the Student, in the Main () method, by the new statement three objects and the object is initialized, and then through the object access the print () method to the output of the three students information,
How to write
CodePudding user response:
The class Student {
private String name;
Private Integer sex;
Private Integer age;
Public Student (String name) {
this.name=name;
}
Public Student (String name, Integer sex) {
this.name=name;
this.sex=sex;
}
Public Student (String name, Integer sex, Integer age) {
this.name=name;
this.sex=sex;
Enclosing the age=age;
}
Public String print () {
Return "Name:" + Name +... + age;
}
}
This is probably