public Book search(int id) {
Book b = null;
Iterator iter = al.iterator();
while (iter.hasNext()) {
b = (Book) iter.next();
if (b.getBookId() == id) {
break;
}
}
return b;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Book b1 = new Book(1001, "CSDN_1");
Book b2 = new Book(1002, "CSDN_2");
Book b3 = new Book(1003, "CSDN_3");
SaveInfo sa = new SaveInfo();
sa.save(b1);
sa.save(b2);
sa.save(b3);
sa.del(b2);
Book bs = (Book) sa.search(1001);
System.out.println("查询结果 " + bs.getBookId() + " " + bs.getBookName());
}
}
/*class CD {
private int cdId;
private String cdName;