Hello दोस्तों! आज इस पोस्ट में आपको Nested Class in Java in Hindi – जावा में नेस्टेड क्लास क्या है? को पढ़ेंगे,, इस पोस्ट को आप पूरा पढ़िए. इस article को बहुत ही आसान और सरल भाषा में लिखा गया है. यह article आपके exam के लिए बहुत उपयोगी साबित होगी. जो छात्र परीक्षा की तैयारी रहे हैं वो सभी इस article (C लैंग्वेज क्या है C language in hindi )की मदद से आप सभी आसानी से हिंदी भाषा में सीख सकते हैं |
Table of Contents
Nested Class in Java in Hindi – जावा में नेस्टेड क्लास क्या है?
नेस्टेड क्लास जब हम एक क्लास को दूसरे क्लास के अंदर परिभाषित करते हैं, तो हम इसे नेस्टेड क्लास कहते हैं। इसका मतलब है कि एक क्लास के अंदर एक और क्लास हो सकता है। नेस्टेड क्लास को प्राइवेट, प्रोटेक्टेड, पब्लिक या पैकेज प्राइवेट तरीके से प्राचलित किया जा सकता है। इसका उपयोग बाहरी क्लास के साथ संबंधित कोड को अधिक संरचित बनाने के लिए किया जाता है।
नेस्टेड क्लास के प्रकार – Types of nested class in java in hindi
नेस्टेड क्लास के तीन मुख्य प्रकार होते हैं |
स्टैटिक नेस्टेड क्लास ( Static nested class )
स्थानीय आंतर क्लास (Local Inner Class )
स्थानीय आंतर क्लास (Local Inner Class)
स्टैटिक नेस्टेड क्लास ( Static nested class in java in hindi )
यह एक स्टैटिक क्लास को एक अन्य क्लास के अंदर परिभाषित करता है और सामान्य बाहरी क्लास के तरह प्राइवेट वस्तुओं तक पहुँचने की अनुमति देता है।
public class OuterClass { // This is an instance variable in the outer class private int outerVar = 10; // This is a static nested class static class StaticNestedClass { // This is a static nested class variable private int nestedVar = 5; void display() { System.out.println("Value of nestedVar: " + nestedVar); } } public static void main(String[] args) { // Create an instance of the outer class OuterClass outer = new OuterClass(); // Create an instance of the static nested class StaticNestedClass nested = new StaticNestedClass(); // Access the members of the static nested class nested.display(); // Access the instance variable of the outer class System.out.println("Value of outerVar: " + outer.outerVar); } } |
“OuterClass” में हम एक बाहरी चरण “outerVar” घोषित कर रहे हैं, जिसका मूल्य 10 है।
“StaticNestedClass” एक स्थैतिक नेस्टेड कक्षा है और इसमें हम एक स्थैतिक नेस्टेड कक्षा चरण “nestedVar” घोषित कर रहे हैं, जिसका मूल्य 5 है।
“StaticNestedClass” के भीतर हम “display” नामक एक चरण भी दिखा रहे हैं, जिसमें हम “nestedVar” की मूल्य प्रिंट कर रहे हैं।
“main” चरण में हम “OuterClass” का एक उदाहरण बना रहे हैं और “StaticNestedClass” का एक उदाहरण बना रहे हैं। फिर हम स्थैतिक नेस्टेड कक्षा के सदस्यों का पहुँच कर उनका प्रदर्शन कर रहे हैं और बाहरी कक्षा के उदाहरण चरण का उपयोग करके “outerVar” की मूल्य को प्रिंट कर रहे हैं।
यह कोड बाहरी और स्थैतिक नेस्टेड कक्षाओं का उपयोग करके दिखाता है कि कैसे इनका उपयोग किया जाता है और उनके सदस्यों तक कैसे पहुँचा जाता है।
OutPut
Value of nestedVar: 5 Value of outerVar: 10 |
गैर-स्टैटिक नेस्टेड क्लास या Inner Class (Non-Static Nested Class in Hindi)
इसे एक बाहरी क्लास के अंदर परिभाषित किया जाता है और यह उस क्लास के सभी सदस्यों तक पहुँचने की अनुमति देता है।
Example
public class OuterClass { // This is an instance variable in the outer class private int outerVar = 10; // This is an inner class (non-static nested class) class InnerClass { // This is an instance variable in the inner class private int innerVar = 5; void display() { System.out.println("Value of innerVar: " + innerVar); System.out.println("Value of outerVar: " + outerVar); // Accessing outer class variable } } public static void main(String[] args) { // Create an instance of the outer class OuterClass outer = new OuterClass(); // Create an instance of the inner class InnerClass inner = outer.new InnerClass(); // Access the members of the inner class inner.display(); } } |
Output
Value of innerVar: 5 Value of outerVar: 10 |
स्थानीय आंतर क्लास (Local Inner Class in hindi)
इसे एक ब्लॉक के अंदर परिभाषित किया जाता है, जैसे कि एक मेथड के अंदर, और यह उस ब्लॉक के बाहरी कोड तक पहुँचने की अनुमति नहीं देता है।
Example
public class OuterClass { private int outerVar = 10; public void outerMethod() { // This is a local inner class defined within the outerMethod class LocalInnerClass { private int innerVar = 5; void display() { System.out.println("Value of innerVar: " + innerVar); System.out.println("Value of outerVar: " + outerVar); // Accessing outer class variable } } // Create an instance of the local inner class LocalInnerClass inner = new LocalInnerClass(); // Access the members of the local inner class inner.display(); } public static void main(String[] args) { // Create an instance of the outer class OuterClass outer = new OuterClass(); // Call the outer method that defines and uses the local inner class outer.outerMethod(); } } |
“main” मेथड में, हम बाहरी कक्षा “OuterClass” का एक उदाहरण बनाते हैं और “outerMethod” मेथड को कॉल करते हैं, जिसमें स्थानीय आंतरिक कक्षा को परिभाषित किया जाता है और उसका उपयोग किया जाता है।
Output
Value of innerVar: 5 Value of outerVar: 10 |
Nested Class in Java के फायदे
- Nested Class in Java से encapsulation बढ़ता है, यानि कि outer class के members को inner class से ही access किया जा सकता है, और inner class को outer class से ही create किया जा सकता है।
- Nested Class in Java से code readability और maintainability में सुधार होता है, क्योंकि nested class को logically group किया जा सकता है, और nested class का use सिर्फ उसी place पर होता है, जहाँ पर वह define हुआ है।
- Nested Class in Java से inheritance में flexibility मिलती है, क्योंकि nested class को outer class से independent interface implement करने में मदद मिलती है, और nested class outer class के methods में parameters की तरह use हो सकती है।
Nested Class in Java के नुकसान
- Nested Class in Java से code complexity बढ़ सकती है, क्योंकि nested class outer class के scope में bound (घिरा) होती है, और nested class outer class के members (private members भी) को access कर सकती है, जिससे confusion create हो सकता है।
- Nested Class in Java से memory consumption बढ़ सकता है, क्योंकि nested class outer class का reference hold (रखती) होती है, और nested class outer class के objects (instances) create (बनाने) पर memory allocate (प्रदान) होती है, जिससे memory leak (नुकसान) हो सकता है।
- Nested Class in Java से performance degradation (कमी) हो सकता है, क्योंकि nested class outer class के methods call (पुकारने) पर load (लोड) होती है, और nested class outer class के members access (पहुंचने) पर extra overhead (मेहनत) होती है, जिससे execution time (समय) increase (बढ़) सकता है।
You Might also like…… Operator in java, जावा मे operators क्या है ? Operators कितने प्रकार के होते है ?
Nested Class in Java in Hindi – जावा में नेस्टेड क्लास क्या है? Faqs
स्टैटिक नेस्टेड क्लास क्या होता है?
स्टैटिक नेस्टेड क्लास एक अंतर्निहित वर्ग है जो एक अन्य क्लास के भीतर स्थायी रूप से परिभाषित किया जाता है
स्टैटिक नेस्टेड क्लास क्या होता है?
स्टैटिक नेस्टेड क्लास एक जटिलता भरे जगह है जिसमें हम स्टैटिक नेस्टेड क्लास के बारे में मूल जानकारी प्राप्त करते हैं।
CONCLUSION :-
आज के इस आर्टिकल मे हमने Nested Class in Java in Hindi – जावा में नेस्टेड क्लास क्या है? के बारे मे विस्तार से जाना आशा है की यह ARTICAL (Nested Class in Java in Hindi – जावा में नेस्टेड क्लास क्या है?) आप के लिए HELPFUL रहा होगा | अगर यह ARTICAL आप को पसंद आया हो तो इसे अपने दोस्तों के साथ SHARE जरूर करे | आप हमे COMMENT के माध्यम से सुझाव दे सकते है आप हमे Email-id studentinsidelibarary013@gmail.com पर अपने सुझाव दे सकते है |
Nested Class in Java in Hindi – जावा में नेस्टेड क्लास क्या है?
Wow wonderful blog layout How long have you been blogging for you make blogging look easy The overall look of your site is great as well as the content
I just wanted to express my gratitude for the valuable insights you provide through your blog. Your expertise shines through in every word, and I’m grateful for the opportunity to learn from you.
What i dont understood is in reality how youre now not really a lot more smartlyfavored than you might be now Youre very intelligent You understand therefore significantly in terms of this topic produced me personally believe it from a lot of numerous angles Its like women and men are not interested except it is one thing to accomplish with Woman gaga Your own stuffs outstanding Always care for it up
Your blog is a breath of fresh air in the often stagnant world of online content. Your thoughtful analysis and insightful commentary never fail to leave a lasting impression. Thank you for sharing your wisdom with us.
I do trust all the ideas youve presented in your post They are really convincing and will definitely work Nonetheless the posts are too short for newbies May just you please lengthen them a bit from next time Thank you for the post
My brother recommended I might like this web site He was totally right This post actually made my day You cannt imagine just how much time I had spent for this information Thanks
Temp mail For the reason that the admin of this site is working, no uncertainty very quickly it will be renowned, due to its quality contents.
Wonderful web site Lots of useful info here Im sending it to a few friends ans additionally sharing in delicious And obviously thanks to your effort
Fantastic beat I would like to apprentice while you amend your web site how could i subscribe for a blog site The account helped me a acceptable deal I had been a little bit acquainted of this your broadcast offered bright clear concept
I just wanted to drop by and say how much I appreciate your blog. Your writing style is both engaging and informative, making it a pleasure to read. Looking forward to your future posts!
I have been browsing online more than three hours today yet I never found any interesting article like yours It is pretty worth enough for me In my view if all website owners and bloggers made good content as you did the internet will be a lot more useful than ever before
I’ve been following your blog for some time now, and I’m consistently blown away by the quality of your content. Your ability to tackle complex topics with ease is truly admirable.
Simply Sseven I very delighted to find this internet site on bing, just what I was searching for as well saved to fav
Its like you read my mind You appear to know so much about this like you wrote the book in it or something I think that you can do with a few pics to drive the message home a little bit but instead of that this is excellent blog A fantastic read Ill certainly be back
ümraniye elektrikçi SEO çalışmaları, Google’da rakiplerimizi geçmemizi sağladı. https://royalelektrik.com/istanbul-elektrikci/
أنابيب الصلب المجلفن في العراق تُعرف مصنع إيليت بايب كواحدة من أفضل وأكثر الشركات المصنعة لأنابيب الصلب المجلفن موثوقية في العراق. تُنتج أنابيب الصلب المجلفن لدينا بدقة ومعايير عالية الجودة، مما يضمن المتانة ومقاومة التآكل. هذه الأنابيب مثالية لمجموعة متنوعة من التطبيقات، بما في ذلك إمدادات المياه، والبناء، والاستخدامات الصناعية. بفضل مرافقنا الحديثة والتزامنا بالتميز، أنشأت مصنع إيليت بايب سمعة قوية في تقديم منتجات عالية الجودة تلبي احتياجات عملائنا بفعالية. اكتشف المزيد عن أنابيب الصلب المجلفن لدينا بزيارة موقعنا الإلكتروني على ElitePipe Iraq.
Yatırım bonusu Google SEO, işimizi büyütmek için mükemmel bir araç. http://www.royalelektrik.com/