在java中 二.编写实体类 在src/main/java目录下创建一个实体类AppointmentInfo,对应数据库中的appointment_info表,包含以上字段,同时添加getters和setters方法。
时间: 2024-02-26 09:56:51 浏览: 31
好的,您需要在src/main/java目录下创建一个名为AppointmentInfo的Java类,并为其添加以下属性和方法:
```
public class AppointmentInfo {
private int id;
private String name;
private Date appointmentDate;
private String description;
// 添加构造函数
public AppointmentInfo(int id, String name, Date appointmentDate, String description) {
this.id = id;
this.name = name;
this.appointmentDate = appointmentDate;
this.description = description;
}
// 添加getters和setters方法
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getAppointmentDate() {
return appointmentDate;
}
public void setAppointmentDate(Date appointmentDate) {
this.appointmentDate = appointmentDate;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
```
这样就可以创建一个名为AppointmentInfo的实体类,其中包含了id、name、appointmentDate、description属性以及对应的getters和setters方法。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![java](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)