这一段java实体类 包含 姓名 年龄 籍贯 性别字段
时间: 2023-08-25 07:04:23 浏览: 86
```java
public class Person {
private String name;
private int age;
private String hometown;
private String gender;
public Person(String name, int age, String hometown, String gender) {
this.name = name;
this.age = age;
this.hometown = hometown;
this.gender = gender;
}
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 getHometown() {
return hometown;
}
public void setHometown(String hometown) {
this.hometown = hometown;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
}
```
以上是一个Java实体类,包含了姓名、年龄、籍贯、性别四个字段,并提供了相应的getter和setter方法。
阅读全文