U
U
Urukhayy2016-01-28 19:05:04
Java
Urukhayy, 2016-01-28 19:05:04

Is it necessary to remove unnecessary class instances (instances) in Java?

Is it necessary to remove unnecessary class instances (instances) in Java?
If yes, how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Dorofeev, 2016-01-28
@Urukhayy

No, the garbage collector will do it for you.
But you can subtly hint to it by giving the
object a reference to null.
For example:

MyClass instanceOfMyClass = new MyClass();
 instanceOfMyClass = null;

But not the fact that the cleaner will come down to this.
Link to articles: first and second

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question