0
Destructor in Java?
Hey, normally I don't ask questions in here, but I just completed a quiz and there was the question "how many destructors can a class have", since when are there destructors in Java? And how do I implement them? Never heard of that... Thx for reading, have a nice day :D
3 odpowiedzi
+ 1
Every programming language that follows oop concept and uses classes has destructors
0
Destructors run when obj of that class is destructor and are optional and only one in no.
0
Destructor is a method that is opposite to constructor. It's called when an object is destroyed.
There's no destructor in Java, but there is finalize() that works as same as a destructor. It's called finalizers. Some website says that finalizers are destructor in Java.
Also, unless you need to manage memory manually, you don't really need finalizers because there is Garbage collector to do it for you automatically.
https://www.javatpoint.com/java-destructor