데이터 클래스(Data Class)

데이터 클래스 설명 및 특징

데이터 클래스의 조건

데이터 클래스가 자동 생성하는 메서드

equals()와 hasCode()예

val cus1 = Customer("Tom", "[email protected]")
val cus2 = Customer("Tom", "[email protected]")
...
println(cus1 == cus2) // 동등성 비교
println(cus1.equals(cus2)) //위와 동일
println("${cus1.hashCode()}, ${cus2.hashCode()}")// 고유값도 동일

/* 실행 결과
true
true
-1208413004, -1208413004
*/