add(new Book(3, "The Debt to Pleasure", "John Lanchester")); Map<Integer, Book> bookMap = new HashMap(); for (Book b : bookList) { bookMap.put(b.getId(), b); } System.out.println("BookMap " + bookMap.toString()); } } Output: BookMap {1=Book{ bookName="Barney's ...