0
In java destructor is replaced with the keyword
finalise
10 odpowiedzi
+ 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
+ 2
Pro Coder never heard of that....need to do more research
Please provide a link of your code for the same
+ 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.
+ 1
Rishi Anand I have never used a destructor before but it exists and is there in my book of Java
+ 1
Pro Coder mention the name and author of the book.....i'll refer that
+ 1
Pro Coder m not able to find the PDF version of this book online.....but have gone through some other ICSE books, stack overflow etc there it is clearly mentioned that there is no destructor in Java
The syntax that you mentioned above is for c++
https://www.edureka.co/community/3255/is-there-a-destructor-in-java
https://www.quora.com/What-is-constructor-and-destructor-in-java
https://books.google.co.in/books?id=oZkjqpHPAb4C&pg=PA24&lpg=PA24&dq=icse+java+destructor&source=bl&ots=m5Sy998unf&sig=SqYO7cb3vkvHIQSoTAkL6IxsXXc&hl=en&sa=X&ved=2ahUKEwi8_YzE-oDfAhUHs48KHXGzAZMQ6AEwGHoECAAQAQ#v=onepage&q=icse%20java%20destructor&f=false
https://www.sololearn.com/discuss/1484361/?ref=app
+ 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?
+ 1
Rishi Anand Thanks for the information!
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(~)
0
Rishi Anand
Total Computer Applications by Ravi Khurana and P. S. Latika