2. 编写一个JavaBean,类名为title,类中包含recID、title、type、price等属性
时间: 2023-07-10 14:03:11 浏览: 58
以下是title这个JavaBean的代码:
```java
public class title {
private int recID;
private String title;
private String type;
private double price;
public int getRecID() {
return recID;
}
public void setRecID(int recID) {
this.recID = recID;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
```
在这个JavaBean中,我们定义了四个属性,分别是recID、title、type和price。其中,recID是一个整数类型,title和type是字符串类型,price是一个双精度浮点数类型。我们为每个属性都提供了getter和setter方法,以便其他类可以访问和修改这些属性。