Out of curiosity,
Why is the finalize()
method's access modifier is made as protected
. Why cant it be public
? Can someone explain me any specific reason behind this?
Also, I came to know that finalize()
method is called only once. If I call it twice in my program internally, what is happening? Will the garbage collector call this again?
private void dummyCall() {
try {
finalize();
finalize();
} catch (Throwable e) {
e.printStackTrace();//NOT REACHES EXCEPTION
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…