code and answer of Java 7: A Beginner's Tutorial