Java course homework