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

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.
主站蜘蛛池模板: 桃江县| 河池市| 双鸭山市| 乐清市| 宜城市| 扶风县| 孝义市| 湖北省| 和静县| 娱乐| 葵青区| 湘潭县| 东辽县| 顺昌县| 永福县| 巩留县| 霍林郭勒市| 商城县| 望奎县| 略阳县| 蒲城县| 岳西县| 湘潭市| 车致| 柳江县| 瓮安县| 通州市| 达拉特旗| 南安市| 阳东县| 河东区| 咸丰县| 遂宁市| 运城市| 浏阳市| 清水河县| 九龙城区| 闵行区| 临汾市| 崇左市| 井冈山市|