#Destroy objects ?
22 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @wide olive! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
There's autocloseable interface you could implement
This is done by IO stuff to close the underlying resources
But as long as it's standard java objects, you can just ignore it, the gc will take care of it
Yeah but that's IO, in this case we're trying to implement a composition as described in UML
You can set any property to null, as long as it's not final
But I might be misunderstanding the question. Do you have a practical example?
It's as concret as this :p
Yeah, but in which function do I inject this line ? Like, is there a function that gets called before the destruction of an object, where I can remove the references (and potentially do other stuff) ?
The teacher's answer is to put, in this case, B as a inner class for A
No, those were finalizers and those are deprecated
In Java you don't have to remove references
Just don't reference the object anymore
The garbage collector will take care of the rest
Cool, thanks for the clarification =)
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.