首页 > 代码库 > 图书类 属性私有,生成其共有的get/set
图书类 属性私有,生成其共有的get/set
public class Book0 { /** * @param args */ public static void main(String[] args) { // TODO 自动生成的方法存根 Book1 book = new Book1("123456","Java","zhangsan","zzzzzz",59); book.show(); }}class Book1{ private String bookId; private String bookName; private String author; private String publisher; private int price; public Book1(){ } public Book1(String bookId,String bookName,String author,String publisher,int price){ this.bookId=bookId; this.bookName=bookName; this.author=author; this.publisher=publisher; this.price=price; } public void show(){ System.out.println("书籍编号:"+bookId); System.out.println("书名:"+bookName); System.out.println("作者名:"+author); System.out.println("出版社:"+publisher); System.out.println("价钱:"+price); } public String getBookId() { return bookId; } public void setBookId(String bookId) { this.bookId = bookId; } public String getBookName() { return bookName; } public void setBookName(String bookName) { this.bookName = bookName; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getPublisher() { return publisher; } public void setPublisher(String publisher) { this.publisher = publisher; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; }
图书类 属性私有,生成其共有的get/set
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。