A Java homework