This is an accepted idiom in C++, but I don't think it makes much sense in Java, since there are no destructors.