Adding the Java code