Mohd Saddam
Mohd Saddam

Reputation: 1

In finalize() method statement written after the call to superclass finalize() method will execute?

In finalize() method the statement written after the call to superclass finalize() method will execute or not?

Upvotes: 0

Views: 59

Answers (1)

user207421
user207421

Reputation: 310893

Not necessarily. An exception might be thrown. But you shouldn't have any code after that anyway. The correct form is:

protected void finalize() throws Throwable
{
    try
    {
        // your code here ...
    }
    finally
    {
        super.finalize();
    }
}

Upvotes: 1

Related Questions