finalize() Method in Java जावा में फाइनलाइज़ मेथड
In Java, when an object holds resources like file handles, fonts, or native system resources, we often need a mechanism to clean them up before the object is destroyed. This process is known as Finalization . जावा में जब कोई ऑब्जेक्ट फाइल हैंडल, विंडोज फॉन्ट्स जैसे रिसोर्सेज से जुड़ा होता है, तो ऑब्जेक्ट के नष्ट होने से पहले इन रिसोर्सेज को मुक्त करना ज़रूरी होता है। इस प्रक्रिया को Finalization कहते हैं। For this, Java provides a special method called finalize() . You can define this method in your class to perform cleanup tasks before the object is garbage collected. इसके लिए जावा में एक विशेष मेथड finalize() होता है। इस मेथड को अपनी क्लास में डिफाइन करके हम वह कार्य कर सकते हैं जो किसी ऑब्जेक्ट के नष्ट होने से ठीक पहले किए जाने चाहिए। This method is called automatically by the Garbage Collector just before an object is destroyed. The garbage collector runs periodically and destroys objects that no longer have any active references. यह मेथड ऑब्जेक्ट के नष्ट होने से पहले स्वतः ...