Enum.finalize() has the following syntax.
protected final void finalize()
In the following code shows how to use Enum.finalize() method.
/*from ww w . j a va 2s .c o m*/ enum Tutorial { CSS(400), HTML(250); int price; Tutorial(int p) { price = p; } int showPrice() { return price; } } public class Main { public static void main(String args[]) { Main t = new Main() { protected final void finalize() { } }; for(Tutorial m : Tutorial.values()) { System.out.println(m + " costs " + m.showPrice() + " dollars"); } } }
The code above generates the following result.