Java Enum.finalize()
Syntax
Enum.finalize() has the following syntax.
protected final void finalize()
Example
In the following code shows how to use Enum.finalize() method.
/* w ww . j a v a 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.