Implementation in java