If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
Java में output print करने के लिए println() और print() methods का use किया जाता है।
println() method , किसी भी output को हमेशा new line से ही print करता है। और need के according आप कितनी बार ही इसका use कर सकते हैं।
File : Test.java
public class Test
{
// main method.
public static void main(String[] args)
{
System.out.println("Hello learners");
System.out.println("Here you will learn programming tutorials");
System.out.println("Also programming related blogs.");
}
}
javac Test.java java Test Hello learners Here you will learn programming tutorials Also programming related blogs.
Example में आप देख सकते हैं , कि println() method में जो कुछ भी print कराया वो new line से ही print हुआ है।
print() method का use करके भी आप output print करा सकते हैं , लेकिन वो new line न print होकर एक ही line में print हो जायगा।
See Example :
File : Test.java
public class Test
{
// main method.
public static void main(String[] args)
{
System.out.print("Hello learners ");
System.out.print("Here you will learn programming tutorials ");
System.out.print("Also programming related blogs.");
}
}
javac Test.java java Test Hello learners Here you will learn programming tutorials Also programming related blogs.
Example में आप देख सकते हैं कि , print() method सिर्फ new line से output print नहीं करता है , और यही सबसे बड़ा difference है print() और println() method में।
हालाँकि ऐसा नहीं है कि print() method से आप new line से print नहीं कर सकते हैं। print() method से new line में print करने के लिए \n का use किया जाता है।
File : Test.java
System.out.print("Hello learners \n");
System.out.print("Here you will learn programming tutorials \n");
System.out.print("Also programming related blogs.");
println() और print() दोनों methods में आप कोई भी number या valid expression भी print करा सकते हो।
File : Test.java
public class Test
{
public static void main(String[] args)
{
System.out.println(420);
System.out.println(5*4);
}
}
javac Test.java java Test 420 20.
I Hope , अब आप समझ गए होंगे कि Java में output कैसे print करते हैं।
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook