In java destructor is replaced with the keyword | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

In java destructor is replaced with the keyword

finalise

1st Dec 2018, 2:41 PM
Pavithra Selvakumar
Pavithra Selvakumar - avatar
10 Answers
+ 4
There is nothing called destructor in Java as Java supports for automatic garbage collection feature. finalize() is just a method that is called by the garbage collector on the object when the garbage collector determines that there is no reference to that object
1st Dec 2018, 2:52 PM
Rishi Anand
Rishi Anand - avatar
+ 2
Pro Coder never heard of that....need to do more research Please provide a link of your code for the same
1st Dec 2018, 4:22 PM
Rishi Anand
Rishi Anand - avatar
+ 2
Pro Coder because java has automatic garbage collection feature in which the garbage collector find and delete objects that doesn't have any referennce. Garbage collector is under the control of JVM. JVM run garbage collector whenever it sense that memory is running low.
2nd Dec 2018, 11:17 AM
Rishi Anand
Rishi Anand - avatar
+ 1
Rishi Anand I have never used a destructor before but it exists and is there in my book of Java
2nd Dec 2018, 6:28 AM
Coding Niffler
Coding Niffler - avatar
+ 1
Pro Coder mention the name and author of the book.....i'll refer that
2nd Dec 2018, 9:50 AM
Rishi Anand
Rishi Anand - avatar
+ 1
Rishi Anand oh ok My book has info on destructors but no mention of it existing in Java It's a complete Java bk so I thought it being mentioned with Java constructors would mean it to be existing in Java Apparently I was wrong Maybe it is just a general info Important to know alongside constructors.. Why doesn't Java have destructors?
2nd Dec 2018, 11:09 AM
Coding Niffler
Coding Niffler - avatar
+ 1
Rishi Anand Thanks for the information!
2nd Dec 2018, 11:36 AM
Coding Niffler
Coding Niffler - avatar
0
Rishi Anand There is a Destructor in Java It is the same name as the class like a constructor but is preceded with a title sign(~)
1st Dec 2018, 4:08 PM
Coding Niffler
Coding Niffler - avatar
0
Rishi Anand Total Computer Applications by Ravi Khurana and P. S. Latika
2nd Dec 2018, 9:53 AM
Coding Niffler
Coding Niffler - avatar