java编写一个student类,包含姓名,性别,年龄
时间: 2023-06-02 13:04:43 浏览: 314
好的,我可以帮您解答这个问题。以下是一个Java编写的Student类的示例,包含姓名、性别和年龄属性:
```
class Student {
private String name;
private String gender;
private int age;
public Student(String name, String gender, int age) {
this.name = name;
this.gender = gender;
this.age = age;
}
public String getName() {
return name;
}
public String getGender() {
return gender;
}
public int getAge() {
return age;
}
public void setName(String name) {
this.name = name;
}
public void setGender(String gender) {
this.gender = gender;
}
public void setAge(int age) {
this.age = age;
}
}
```
您可以根据需要自定义其它方法或属性。希望对您有所帮助!
阅读全文