Practising some Java codes