Java codes(Practice)