官术网_书友最值得收藏!

Canonical methods

Canonical methods are the methods declared in Any. Therefore, all instances in Kotlin have them.

For data classes, Kotlin creates correct implementations of all canonical methods.

The methods are as follows:

  • equals(other: Any?): Boolean: This method compares value equivalence, rather than reference.
  • hashCode(): Int: A hash code is a numerical representation of an instance. When hashCode() is invoked several times in the same instance, it should always return the same value. Two instances that return true when they are compared with equals must have the same hashCode().
  • toString(): String: A String representation of an instance. This method will be invoked when an instance is concatenated to a String.
主站蜘蛛池模板: 克什克腾旗| 兴仁县| 阿坝| 灵丘县| 青岛市| 亳州市| 烟台市| 临沭县| 铜山县| 门源| 华坪县| 南丹县| 衡水市| 左贡县| 金溪县| 乐清市| 青海省| 樟树市| 岑溪市| 托克逊县| 凉山| 连江县| 灵武市| 天津市| 云和县| 吴川市| 西昌市| 久治县| 探索| 乌拉特后旗| 沂南县| 许昌市| 布拖县| 潍坊市| 兖州市| 梨树县| 安吉县| 依安县| 上蔡县| 包头市| 阳曲县|