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

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.
主站蜘蛛池模板: 天台县| 定结县| 彭山县| 虹口区| 浦江县| 武威市| 和林格尔县| 大埔县| 炉霍县| 夹江县| 红原县| 临清市| 海安县| 沂源县| 常熟市| 屯留县| 门头沟区| 绥化市| 泗洪县| 绥化市| 昂仁县| 中方县| 平潭县| 黄浦区| 巴彦淖尔市| 陆良县| 阳春市| 曲松县| 正安县| 来宾市| 龙州县| 西吉县| 千阳县| 舒城县| 赤水市| 宝坻区| 彭州市| 文成县| 浠水县| 长宁县| 黄平县|