Can you set an object to null in Java?

Setting an object to null, clears the reference . If there is no longer any reference to that object, as in your first example, the memory can be freed, when the JVM runs the GC (Grarbage Collector) the next time.

Sizin İçin Seçtik  15 tl kaç dolar olur?

Leave a Reply

Your email address will not be published. Required fields are marked *