Write a program in java to finalize method?

class Finalize

{

      public void finalize()

      {

            System.out.println("Finalize Called");

      }

      public static void main(String arg[])

      {

            Finalize f1=new Finalize();

            //Finalize f2=new Finalize();

            f1=null;

            //f2=null;

            System.gc();

      }

}

Finalize Method.PNG

, , , , ,

Leave a Reply