Learning and implementing  java code