Posts

Showing posts with the label static keyword

Java static Keyword – Explained with Examples जावा का स्टेटिक कीवर्ड – उदाहरणों सहित विस्तृत जानकारी

The static keyword in Java is primarily used for memory management . It can be applied to variables, methods, blocks, and nested classes. A static member belongs to the class rather than an instance , so it is shared among all objects of the class. जावा में स्टेटिक कीवर्ड का प्रयोग मुख्य रूप से मेमोरी प्रबंधन के लिए किया जाता है। इसे वेरिएबल, मेथड, ब्लॉक और नेस्टेड क्लास में प्रयोग किया जा सकता है। एक स्टेटिक सदस्य क्लास का होता है, न कि किसी विशेष ऑब्जेक्ट का, इसलिए यह सभी ऑब्जेक्ट्स के बीच साझा होता है। 🔹 Uses of static Keyword स्टेटिक कीवर्ड के अनुप्रयोग The static keyword is used with: Static Block Static Variable Static Method Static Class (Nested only) स्टेटिक कीवर्ड का उपयोग निम्न के साथ किया जाता है: स्टेटिक ब्लॉक स्टेटिक वेरिएबल स्टेटिक मेथड स्टेटिक क्लास (केवल नेस्टेड) 🔸 Static Block स्टेटिक ब्लॉक A static block is used to initialize static variables before the main method is executed. It runs only once when the class is loaded. St...