implement the code examples in Core Java 9th ed