A simple java exercise