simple java exercise