Object#finalize()
is a protected
method. You can't call it like that. A protected
member of a class is inherited by it's direct subclass. You can access it inside that direct subclass on this
reference, but not using the reference of that class directly.
It would be like this:
class Demo {
public void test() {
this.finalize();
}
}
BTW, why do you want to invoke it? That method is automatically invoked by JVM to clear any resources that an object is using, just before the object is completely removed from the memory.