java code for the first solution of Chapter6