java.lang.Enum.finalize()


java.lang.Enum.finalize()

package com.codingdict;



import java.lang.*;



// enum showing Mobile prices

enum Mobile {

   Samsung(400), Nokia(250);



   int price;

   Mobile(int p) {

      price = p;

   }

   int showPrice() {

      return price;

   } 

}



public class EnumDemo {



   public static void main(String args[]) {



      System.out.println("enum class cannot have finalize methods...");       

      EnumDemo t = new EnumDemo() {

         protected final void finalize() { }    

      }; 



      System.out.println("CellPhone List:");

      for(Mobile m : Mobile.values()) {

         System.out.println(m + " costs " + m.showPrice() + " dollars");

      }                    

   }

}