update function in java 2