Updated Java code