Java Basic course homework