public class BookCollection
1: //BookCollection.java
3: import java.util.HashSet;
5: public class BookCollection
6: {
7: public static void main(String[] args)
8: {
9: HashSet<String> ownedBooks = new HashSet<String>();
11: ownedBooks.add("A Tale of Two Cities");
12: ownedBooks.add("The Lord of the Rings");
14: System.out.println
15: (
16: "Contains \"A Tale of Two Cities\": "
17: + ownedBooks.contains("A Tale of Two Cities")
18: );
20: ownedBooks.remove("The Lord of the Rings");
22: System.out.println
23: (
24: "Contains \"The Lord of the Rings\": "
25: + ownedBooks.contains("The Lord of the Rings")
26: );
27: }
28: }