Kotlin - Data Classes

In this liquidation we speak Data exercises of Kotlin programming language.

We can make Data superbness on each event it is set apart as “information"

Whenever a classification is set apart as insights, we can utilize a portion of the in-fabricated normal for that measurements tastefulness comprehensive of "toString()","hashCode()", and numerous others.

fun primary(args: Array) val digital book: Book = Book("Kotlin", "welookups.Com", 5) println("Name of the Book is- - "+ebook.Name)/"Kotlin" println("Puclisher Name- - "+book.Publisher)/"welookups.Com" println("Review of the book is- - "+e-book.ReviewScore)/5 e book.ReviewScore = 7 println("Printing all the data all together- - "+e book.ToString()) /the utilization of in-assembled normal for the certainties superbness println("Example of the hashCode work - "+e book.HashCode()) data class Book(val call: String, val distributer: String, var reviewScore: Int)

The above bit of code will yield the accompanying yield in the program, where we have made one data tastefulness to save some of the information, and from the essential capacity we have gotten to the majority of its data participants.

Whenever a class is marked as data, we can use some of the inbuilt function of that data class such as “toString()”,”hashCode()”, etc. A style="display: inline-block; border:2px solid #6bf442; background-color:#f4d341">fun main(args: Array<String>) { val book: Book = Book("Kotlin", "welookups.com", 5) println("Name of the Book is--"+book.name) // "Kotlin" println("Puclisher Name--"+book.publisher) // "welookups.com" println("Review of the book is--"+book.reviewScore) // 5 book.reviewScore = 7 println("Printing all the info all together--"+book.toString()) //using inbuilt function of the data class println("Example of the hashCode function--"+book.hashCode()) } data class Book(val name: String, val publisher: String, var reviewScore: Int)