code written when I study Head First Java