编写一个javabeanbook.java它含有属性bookid,bookname,bookprice并编写getter,setter
时间: 2024-02-20 16:59:41 浏览: 132
好的,以下是JavaBean Book类的代码:
```java
public class Book {
private int bookid;
private String bookname;
private double bookprice;
public int getBookid() {
return bookid;
}
public void setBookid(int bookid) {
this.bookid = bookid;
}
public String getBookname() {
return bookname;
}
public void setBookname(String bookname) {
this.bookname = bookname;
}
public double getBookprice() {
return bookprice;
}
public void setBookprice(double bookprice) {
this.bookprice = bookprice;
}
}
```
这个JavaBean类包含了三个属性:`bookid`、`bookname`和`bookprice`,以及对应的getter和setter方法。getter方法用于获取属性的值,setter方法用于设置属性的值。这样,我们就可以通过JavaBean对象来访问和修改这些属性的值了。
阅读全文