
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java System runFinalization() Method
Description
The Java System runFinalization() method runs the finalization methods of any objects pending finalization.
Declaration
Following is the declaration for java.lang.System.runFinalization() method
public static void runFinalization()
Parameters
NA
Return Value
This method does not return any value.
Exception
NA
Example: Running finalization
The following example shows the usage of Java System runFinalization() method. In this program, we've created a File Object and printed it identity hash code. Then we've printed the system time in milliseconds. Finally using runFinalization() method, finalization call is run for any objects pending finalization.
package com.tutorialspoint; public class SystemDemo { public static void main(String[] args) throws Exception { File file1 = new File("abcd"); // returns the HashCode int ret = System.identityHashCode(file1); System.out.println(ret); // returns the current value of the system timer, in milliseconds System.out.print("time in milliseconds = "); System.out.println(System.currentTimeMillis()); System.out.println("finalization of any objects pending finalization!"); System.runFinalization(); System.out.println("Done!!!"); } }
Output
Let us compile and run the above program, this will produce the following result −
355165777 time in milliseconds = 1350971291853 finalization of any objects pending finalization! Done!!!
java_lang_system.htm
Advertisements