Public Static Void Main in Java
Public Static Void Main in Java
In Java, the `public static void main(String args[])` method is the entry point for a Java program. It is the first method that is executed when you run a Java application.
Let's break down the parts of this method signature:
- `public`: This is an access modifier, indicating that the `main` method can be accessed from anywhere within the program. It allows the method to be called by the Java runtime system.
- `static`: This keyword indicates that the `main` method belongs to the class itself rather than an instance of the class. It allows the method to be invoked without creating an object of the class.
- `void`: This is the return type of the `main` method, indicating that it does not return any value. The `main` method is meant to execute the program, rather than produce a result.
- `main`: This is the name of the method. It is a convention in Java to have the entry point method named `main`.
- `String args[]`: This is the parameter passed to the `main` method. It is an array of strings (`String[]`) named `args`. The `args` array allows you to pass command-line arguments to your Java program when you run it. These arguments can be accessed within the `main` method and used in your program.
To put it simply, the `public static void main(String args[])` method is the starting point of a Java program. It is where the execution begins, and you can use it to write the initial code that will be executed when the program runs.
हिंदी:
जावा में, `public static void main(String args[])` मेथड जवाकार्यक्रम का प्रवेश बिंदु होता है। यह वह पहला मेथड होता है जो जब आप एक जावा एप्लिकेशन को चलाते हैं, तब क्रियान्वयन किया जाता है।
आइए इस मेथड के अंगों को विस्तार से समझते हैं:
- `public`: यह एक पहुंच मोडीफायर है, जो इंटरनल प्रोग्राम से `main` मेथड तक पहुंचने की अनुमति देता है। इससे जावा रनटाइम सिस्टम द्वारा मेथड को कॉल किया जा सकता है।
- `static`: यह कीवर्ड इस बात की घोषणा करता है कि `main` मेथड क्लास के अपने आप का हिस्सा है, बल्कि क्लास के एक इंस्टेंस का हिस्सा नहीं है। इससे यह मेथड बिना किसी क्लास इंस्टेंस को बनाए उपयोग किए जा सकते हैं।
- `void`: यह `main` मेथड का वापसी प्रकार है, इसका अर्थ है कि यह कोई मान वापस नहीं करता है। `main` मेथड का उद्देश्य क्रियान्वयन करना होता है, बल्कि कोई परिणाम प्राप्त करना नहीं।
- `main`: यह मेथड का नाम है। जावा में एक प्रोग्राम के प्रवेश बिंदु मेथड को `main` के नाम से रखना जावा की एक प्रथा है।
- `String args[]`: यह `main` मेथड को पास किए जाने वाले पैरामीटर हैं। यह एक स्ट्रिंगों (`String[]`) का एक एरे है जिसका नाम `args` है। `args` एरे की मदद से आप जब अपनी जावा प्रोग्राम को चलाते हैं तो कमांड लाइन आर्ग्यूमेंट्स को पास कर सकते हैं। ये आर्ग्यूमेंट्स `main` मेथड के भीतर प्राप्त किए जा सकते हैं और आप उन्हें अपने प्रोग्राम में उपयोग कर सकते हैं।
सरल शब्दों में कहें तो, `public static void main(String args[])` मेथड एक जावा प्रोग्राम का प्रारंभिक बिंदु होता है। यहां से नया कार्यान्वयन शुरू होता है, और आप इसे अपने प्रोग्राम में क्रियान्वित करने के लिए शुरुआती कोड लिख सकते हैं।
Post a Comment