Code for Java