Code example for DataInput

Methods: readFloat, readInt

0
        this.similarity = similarity;
    } 
 
    @Override 
    public void readFields(DataInput in) throws IOException {
        id = in.readInt();
        similarity = in.readFloat();
    } 
 
    @Override 
    public void write(DataOutput out) throws IOException {
        out.writeInt(id);
        out.writeFloat(similarity);
    } 
 
    @Override 
    public boolean equals(Object o) {
        if (o == this)
            return true; 
        if (o instanceof HalfPair) {
            HalfPair hp = (HalfPair) o;