A
A
Alexander Morgunov2018-03-21 13:26:53
Kotlin
Alexander Morgunov, 2018-03-21 13:26:53

Destructor of a class object in Kotlin, does it exist?

Hello everyone, not so long ago I started to learn Java and Kotlin .
So, for the second question, I have a question: how is the destructor described in his class? I googled, of course, but didn't find anything specific. Is there anyone who knows who can tell me the info?
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Varakosov, 2018-03-21
@toruk0109

There is finalize(), which is actually a destructor. However, due to the implementation of memory, it is very rarely used, mainly for complex debugging or optimization of adult projects, when other ways have already been tried. On Android, finalize() is completely useless, since the system specification does not guarantee its implementation.

P
Papa, 2018-03-21
Stifflera @PapaStifflera

So, for the second question, I have a question: how is the destructor described in his class?

No way. They simply don't exist.

E
Evgeny Novoselov, 2018-03-21
@zkod

I may not be competent in this matter.
Kotlin is now translating source code into JVM bytecode.
If the destructor is in Java, then the implementation can be written in Kotlin.
And there is an opportunity to use the translation of the source code from Java -> Kotlin. Or see what the destructor looks like in Java and rewrite it manually in Kotlin.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question