Skip to content

Commit 7f2c52f

Browse files
committed
DataClass was added.
1 parent 90d5ad1 commit 7f2c52f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

DataClassExample.kt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
fun main() {
2+
3+
val student = Student("Halil", "Ozel", 25, "Istanbul")
4+
println(student.component1())
5+
println(student.component2())
6+
println(student.component3())
7+
println(student.component4())
8+
9+
val studentSecond=student.copy(surname = "Ibrahim",city = "Sivas")
10+
println("Student First: ${student.name} - ${student.surname} - ${student.age} - ${student.city}")
11+
println("Student Second: ${studentSecond.name} - ${studentSecond.surname} - ${studentSecond.age} - ${studentSecond.city}")
12+
13+
println(student.toString())
14+
15+
println("Student First hashCode: "+student.hashCode())
16+
println("Student Second hashCode: "+studentSecond.hashCode())
17+
18+
println(student.equals(studentSecond))
19+
}
20+
21+
data class Student(
22+
val name: String,
23+
val surname: String,
24+
val age: Int,
25+
val city: String
26+
)

0 commit comments

Comments
 (0)