Home » Java programming language

Java System class runFinalization() method with example

System class runFinalization() method: Here, we are going to learn about the runFinalization() method of System class with its syntax and example.
Submitted by Preeti Jain, on September 15, 2019

System class runFinalization() method

  • runFinalization() method is available in java.lang package.
  • runFinalization() method is used to run the finalize() methods of any object that are already in a queue for disposing of unused objects.
  • runFinalization() method is a static method, it is accessible with the class name too.
  • runFinalization() method method does not throw any exception.

Syntax:

    public static void runFinalization();

Parameter(s):

  • It does not accept any parameter.

Return value:

The return type of this method is void, it does not return anything.

Example:

// Java program to demonstrate the example of 
// runFinalization () method of System Class

public class RunFinalizationMethod {
    public static void main(String[] args) {
        // print the state of the program
        int i = 10;

        System.out.println("The value of i is :" + i);

        // Here, we are calling the runFinalization() method 
        // that will  call finalize() methods 
        // for disposing unused objects
        Runtime.getRuntime().runFinalization();
        System.out.println("Finalization Done.");
    }
}

Output

E:\Programs>javac RunFinalizationMethod.java
E:\Programs>java RunFinalizationMethod
The value of i is :10
Finalization Done.






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.