集册 Java实例教程 覆盖对象类的finalize()方法的Finalize类

覆盖对象类的finalize()方法的Finalize类

欢马劈雪     最近更新时间:2020-01-02 10:19:05

604
覆盖对象类的finalize()方法的Finalize类

public class Main {

  public static void main(String[] args) {

    // Create many objects, say 20000 objects.

    for(int i = 0; i < 20000; i++) {
    /* from 
    时代Java公众号*/

      new Finalize(i);      

    }  

  }

}

class Finalize {

  private int x;


  public Finalize(int x) {

    this.x = x;

  }


  public void finalize() {

    System.out.println(
展开阅读全文