-
Notifications
You must be signed in to change notification settings - Fork 2
/
DataClassExample.kt
26 lines (20 loc) · 839 Bytes
/
DataClassExample.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
fun main() {
val student = Student("Halil", "Ozel", 25, "Istanbul")
println(student.component1())
println(student.component2())
println(student.component3())
println(student.component4())
val studentSecond=student.copy(surname = "Ibrahim",city = "Sivas")
println("Student First: ${student.name} - ${student.surname} - ${student.age} - ${student.city}")
println("Student Second: ${studentSecond.name} - ${studentSecond.surname} - ${studentSecond.age} - ${studentSecond.city}")
println(student.toString())
println("Student First hashCode: "+student.hashCode())
println("Student Second hashCode: "+studentSecond.hashCode())
println(student.equals(studentSecond))
}
data class Student(
val name: String,
val surname: String,
val age: Int,
val city: String
)