Java System类runFinalization()方法及示例

系统类runFinalization()方法 (System class runFinalization() method)

  • runFinalization() method is available in java.lang package.

    runFinalization()方法在java.lang包中可用。

  • runFinalization() method is used to run the finalize() methods of any object that are already in a queue for disposing of unused objects.

    runFinalization()方法用于运行已在队列中的任何对象的finalize()方法,以处理未使用的对象。

  • runFinalization() method is a static method, it is accessible with the class name too.

    runFinalization()方法是一个静态方法,也可以使用类名进行访问。

  • runFinalization() method method does not throw any exception.

    runFinalization()方法方法不会引发任何异常。

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.

此方法的返回类型为void ,它不返回任何内容。

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.


翻译自: https://www.includehelp.com/java/system-class-runfinalization-method-with-example.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值