Create hash from string and int

前端 未结 6 1945
离开以前
离开以前 2021-02-07 20:14

I remember eclipse and idea have this template to automatically create an object\'s hashCode based on its attributes.

One of the strategies if a number and a string is u

6条回答
  •  没有蜡笔的小新
    2021-02-07 21:01

    You can also use Objects class from java.util.Objects package to quickly get hash code.

    @Override
    public int hashCode() {
        return Objects.hash(this.string, this.integerValue, this.otherDataTypes);
    }
    

提交回复
热议问题