small Java coding exercise