Puzzle from java magazine no.3