
622 CHAPTER 9 Multidimensional Arrays and the ArrayList Class
Figure 9.16
Results of a Search for the
Keyword “Java”
6 import javax.swing.JOptionPane;
7
8 public class BookSearchEngine
9 {
10 public static void main( String []args )
11 {
12 BookStore bs = new BookStore();
13
14 String keyword = JOptionPane.showInputDialog( null,
15 "Enter a keyword" );
16 System.out.println( "Our book collection is:" );
17 System.out.println( bs.toString());
18
19 ArrayList<Book> results = bs.searchForTitle( keyword );
20
21 System.out.println( "The search results for " + keyword
22 + " are:" );
23 for( Book tempBook : results )
24 System.out.println( tempBook.toString());
25 }
26 ...