Java code for learning and other purposes