Updated Java Code