Calling Destructor

Calling Destructor

How can i call destructor in java using System.gc() or manually. Please anyone give me a example program

View Answers

December 20, 2011 at 3:57 PM

Java is a garbage collected language therefore you cannot predict when (or even if) an object will be destroyed. Hence there is no direct equivalent of a destructor.

There is an inherited method called finalize for Garbage Collection.

import java.io.*;
public class FinalizeObject extends FileOutputStream {

// Contructor definition of the FinalizeFileOutputStream class.
public FinalizeFileOutputStream() throws IOException{
super("Rose India"); // call the super class constructor.
}

public static void main(String[] args) throws IOException {

// Create object of FinalizeFileOutputStream class.
FinalizeFileOutputStream objOutstream = new FinalizeFileOutputStream();

// finalize() method call.
objOutstream.finalize();
System.out.print("Stream is closed successfully and connection has "+
"cleaned up to the file.");

}
}

Java Garbage Collection using System.gc()









Related Tutorials/Questions & Answers:
Calling Destructor
Calling Destructor  How can i call destructor in java using System.gc() or manually. Please anyone give me a example program   Java... if) an object will be destroyed. Hence there is no direct equivalent of a destructor
Destructor in java
Destructor in java  Does Java has destructor
Advertisements
ModuleNotFoundError: No module named 'destructor'
ModuleNotFoundError: No module named 'destructor'  Hi, My Python... 'destructor' How to remove the ModuleNotFoundError: No module named 'destructor' error? Thanks   Hi, In your python environment you
video calling
video calling  how to implement video calling using java? i am a final year mca student please give me some samplecodes
video calling
video calling  how to implement video calling using java? i am a final year mca student please give me some samplecodes
PHP Constructor and Destructor
PHP Constructor & Destructor: Like other OOP based languages PHP also... constructor. ADS_TO_REPLACE_1 PHP also supports destructor like C++. This method... can call the destructor method of parent class by parent::__destruct
Calling a function
Calling a function  Hi, I have a function xyz() in php code. When a button is clicked it should execute that particular function for that i have written as <form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
calling servlet from jsp
calling servlet from jsp  how to call a servlet from jsp
php calling variables
php calling variables  Can i call a member variable of a class using static method in php
calling a java file in java
calling a java file in java  how to call a another java file in java
Calling from JSP
Calling from JSP  how can we call a class file from JSP   Hi, Do you want to call a servlet or a Java Bean through JSP? Please clarify this. For more information, visit the following link: JSP Tutorials Thanks
Calling servlet from servlet .
Calling servlet from servlet .  How to call a servlet from another... ServletException, IOException { System.out.println("Calling another servlet by using...); System.out.println("Calling another servlet by using SendRedirect
calling function - JSP-Servlet
calling function  Hai, How to call a java file in jsp file?  Hi friend, Step to be remember for solving the problem : 1.Create a jsp page "test.jsp" Example of Extends Attribute of page
calling method - Java Beginners
calling method   class A{ public void fo(){ class B{ public void fo1(){ System.out.println("fo1 of class B"); } } System.out.println("fo of class A"); } class C{ public void fo2
calling setInterval() on onclick event
calling setInterval() on onclick event  Hi all, I am trying to call setInterval() on onclick event. But it is executing the code only once. Following is my code. <script type="text/javascript" language="javascript">
Calling Constructor in Spring
Calling Constructor in Spring       In the given example you will be learning about a constructor and how to call a constructor in the Spring. Declaring constructor injection
Server calling of .exe file in the client
Server calling of .exe file in the client   I have a requirement with java webapplication. We are using jboss as appserver on Linux machine. How can I call a .exe file from client machine? I want to run .exe from webpage like
Calling awt Frame methods from subclass
Calling awt Frame methods from subclass  Calling awt Frame methods from subclass
calling java beans - JSP-Servlet
calling java beans  Sir, I want to know where to place the java beans java file and class file inside tomcat web server. and how to call them from jsp file.  Hi Friend, Java Bean is placed in classes\form
Calling a jsp page from Servlet
Calling a jsp page from Servlet  How can I do this? Suppose I have jsp page aaa.jsp. From aaa.jsp on form action I have made a call to a servlet xxx.java. In xxx.java I have written code to retrieve data from database through
Calling Action on form load - Struts
Calling Action on form load  Hi all, is it possible to call... this list is coming from the action which i m calling before the page is being... to direct user directly to this page i m calling an action which is preparing a list
calling one jsp from another jsp page
calling one jsp from another jsp page  need coding for calling one jsp from another jsp including the xml file.Its urgent
calling zipping function - JSP-Servlet
calling zipping function  Hi, Is it possible to zip a jsp file. I wrote a java function for zipping a file.How to call that java file (zipping function ) in JSP ? pls help me Thanks.... 
ModuleNotFoundError: No module named 'seaborn-calling-function'
ModuleNotFoundError: No module named 'seaborn-calling-function'  Hi...: No module named 'seaborn-calling-function' How to remove the ModuleNotFoundError: No module named 'seaborn-calling-function' error? Thanks  
ModuleNotFoundError: No module named 'sequana-variant-calling'
ModuleNotFoundError: No module named 'sequana-variant-calling'  Hi...: No module named 'sequana-variant-calling' How to remove the ModuleNotFoundError: No module named 'sequana-variant-calling' error? Thanks   
ModuleNotFoundError: No module named 'django-countries-with-calling-codes'
ModuleNotFoundError: No module named 'django-countries-with-calling-codes' ...: ModuleNotFoundError: No module named 'django-countries-with-calling-codes' How to remove the ModuleNotFoundError: No module named 'django-countries-with-calling
instead of calling an individual ResultSet.getXXX method for each column.
instead of calling an individual ResultSet.getXXX method for each column.  How do I retrieve a whole row of data at once, instead of calling an individual ResultSet.getXXX method for each column
calling from iphone through programitically in iphone
calling from iphone through programitically in iphone  calling from iphone through programitically in iphone please help me my senario is if i click send sms button message should deliver to xyz person and that xyz person make
Calling Namespace
Calling Namespaced Code From Other File: In the previous tutorial we have seen that how to declare a namespace and how to access the class, function from inside the code, now in this current tutorial we will study how to access those
calling webservices that return complexTypes in android using ksoap2
calling webservices that return complexTypes in android using ksoap2   Can anyone direct me to a site or show me an example ,on how to call a webservice which returns a complexType as the result, in an android app
Error in calling javascript function from java
Error in calling javascript function from java  I am callin javascriot function from applet and getting error netscape.javascript.JSException: Unexpected error: This method should not be used unless loaded from plugin.jar
From struts calling function to bean - EJB
From struts calling function to bean   I am calling a function from "struts action class" to bean. I am using weblogic 8.1 web server.i am able to call the function from action class,when i restart the server.But when i
Calling external process in Java - Java Beginners
Calling external process in Java  Hi, How I can call some system command from Java? I want to run the Microsoft Calculator application from Java, how it can be done. Provide me example. What is the use of Runtime.getRuntime
Calling java class method from javascript
Calling java class method from javascript  I want to call a java class method from javascript. The java class method is like "public String[] getWord()". I want to assign this string array value to a variable in javascript. I
calling servlet from jsp in netbeans ide
calling servlet from jsp in netbeans ide  I have tried to call servlet from jsp code in netbeans for checking the database values . but while running it showing the error that the resource not available. i dono wat mistake i did
pyspark : An error occurred while calling None.org.apache.spark.api.java.JavaSparkContext
pyspark : An error occurred while calling None.org.apache.spark.api.java.JavaSparkContext  Hi I am running pyspark code and it was running fine yesterday. Now its giving the error: pyspark : An error occurred while calling
Calling exe through Java program. - Java Beginners
Calling exe through Java program.  Hi, How to call a vb exe that takes one argument , using a Java program. Thank You, Umesh Kilkile  Hi Friend, Try the following code: import java.lang.*; import
calling webservices that return complexTypes in android using ksoap2
calling webservices that return complexTypes in android using ksoap2   Here's my code for android application,to call aweb service method and return...(); } } } }"); The webservice method i am calling retuns
Calling hibernate query list() method generates errors
Calling hibernate query list() method generates errors  Hello, I'm trying to debug someone's codes. But I am not an expert of hibernate so I'm... Collection<JobEntity> getJobsByGrpId(String grpId){ Query q
calling a session bean bean from servlet using netbeans - EJB
calling a session bean from servlet using netbeans  How to call a session bean from servlet using netbeans in Java
core java ,io operation,calling methods using switch cases
core java ,io operation,calling methods using switch cases  How to create a dictionary program,providing user inputs using io operations with switch cases and providing different options for searching,editing,storing meanings
calling a javascript function by passing multiple values from applet in web application
calling a javascript function by passing multiple values from applet in web application  Hi all, I have a requirement like this, I have to call a javascript function from JApplet by passing 3 values. I am new to Applets
calling one jap page from another jsp page
calling one jap page from another jsp page  i created a button in one jsp page i need to call another jsp page as an action to that button. so how can i call.. plz any one explain. its urgent
Implement Java clients calling Web Services
Implement Java clients calling Web Services Prev Chapter 3. Develop clients that access... clients calling Web Services Generating a Java client proxy and a sample
calling servlet from JS and return response from servlet to JS
calling servlet from JS and return response from servlet to JS  hello all, I am working on JSP-servlets n MVC.I am facing a problem. on the web page when user clicks on a button i am calling a javascript function(eg myFunc
calling web page accroding to if statement - JSP-Interview Questions
calling web page accroding to if statement  Dear, Please i have three conditions. Sample pseudocode Program: if answer = '1' I want to call the web page1 by include else if answer = '2' I want to call
Creating objects for classes and calling functions of a dll file using JNI
Creating objects for classes and calling functions of a dll file using JNI  Hi all, I am new to JNI. I am having a dll file created by somebody else. In this file, some c++ classes and functions are available. How can we create
calling one jsp from another jsp - JSP-Servlet
calling one jsp from another jsp  Hi All, In my web application I have two jsp files(one.jsp and two.jsp). I have written a seperate method... is just like calling a method() in the java/c++/c classes. It will call the method
calling a web page when pressing on a Button - JSP-Interview Questions
calling a web page when pressing on a Button  Please perhaps I do not explain my questions clearly: I have three buttons: View, Print and Update. When the user clicks on a button View, I call a web page When the user
ejb calling from jsf - Java Server Faces Questions
ejb calling from jsf  1st i take list of person then i try to edit one of them and then again pass to the ejb to merge it. the ejb function : public FeedBack UpdatePerson(Person objPerson) { try

Ads