System.out.println() in Java
System.out.println() in Java
In Java, `System.out.println()` is a method used to display output on the console or command line. It is part of the `System` class and belongs to the `out` object, which represents the standard output stream.
The `println()` method is used to print a string or value followed by a newline character ('\n'). Here's the general syntax of `System.out.println()`:
System.out.println(value);
Here, `value` can be any data type, such as a string, number, boolean, or object. The `println()` method converts the value to its string representation and displays it on the console.
For example, let's say you want to display the message "Hello, world!" on the console
System.out.println("Hello, world!");
When you run this code, it will print "Hello, world!" on a new line in the console.
You can also use `System.out.print()` without the newline character if you want to display output without moving to the next line:
System.out.print("Hello, ");
System.out.print("world!");
In this case, the output will be "Hello, world!" without a newline character.
Overall, `System.out.println()` is a convenient way to display output and debug your Java programs by printing values to the console.
हिंदी:
Java में, `System.out.println()` एक मेथड है जो कंसोल या कमांड लाइन पर आउटपुट दिखाने के लिए उपयोग होती है। यह `System` क्लास का हिस्सा है और `out` ऑब्जेक्ट का हिस्सा है, जो मानक आउटपुट स्ट्रीम को प्रतिष्ठित करता है।
`println()` मेथड का उपयोग स्ट्रिंग या मान को एक नयी लाइन चर ('\n') के साथ प्रिंट करने के लिए किया जाता है। यहां `System.out.println()` का सामान्य धारा है:
System.out.println(value);
यहां, `value` कोई भी डेटा टाइप हो सकता है, जैसे स्ट्रिंग, नंबर, बूलियन या ऑब्जेक्ट। `println()` मेथड मान को उसके स्ट्रिंग प्रतिरूप में रूपांतरित करके उसे कंसोल पर प्रदर्शित करता है।
उदाहरण के रूप में, मान जैसे "नमस्ते, दुनिया!" को कंसोल पर प्रदर्शित करना चाहते हैं:
System.out.println("नमस्ते, दुनिया!");
जब आप इस कोड को चलाते हैं, तो यह कंसोल में एक नई पंक्ति में "नमस्ते, दुनिया!" प्रिंट करेगा।
आप `System.out.print()` का भी उपयोग कर सकते हैं बिना नयी लाइन चर के अगर आप अगली पंक्ति पर नहीं जाना चाहते हैं:
System.out.print("नमस्ते, ");
System.out.print("दुनिया!");
इस मामले में, आउटपुट "नमस्ते, दुनिया!" होगा बिना नयी लाइन चर के।
सम्ग्रह में, `System.out.println()` एक सुविधाजनक तरीका है जिससे आप जावा प्रोग्राम को डिबग करने और मानों को कंसोल पर प्रिंट करके अपनी प्रोग्राम का आउटपुट देख सकते हैं।
Post a Comment