Click here to Skip to main content
15,883,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sealed class Genre{
sealed class Fiction : Genre(){
    object Classics: Fiction()
    object Fantasy: Fiction()
    object ScienceFiction: Fiction()
}
sealed class NonFiction: Genre(){
    object Biography: NonFiction()
    object Business: NonFiction()
    object Feminism: NonFiction()
    object Politics: NonFiction()
    object SelfHelp: NonFiction()
}

override fun toString(): String {
    return this::javaClass.get().simpleName
}


What I have tried:

I can not understand the use of javaClass in kotlin.
And the use of this::javaClass.get().simpleName, is that because we want to access simpleName?
Can you please explain it in simple words and giving examples.
Thanks.
Posted
Updated 3-Jul-21 5:19am

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900