Thursday, August 20, 2015

Print And Println

Hi All...!

Today I'm going to show you how print a line of text using Java program. To do this task I'm going to use "System" class in Java and it's field call "out" and also println and print methods from PrintStream class.Don't worry about those class, field and methods, you will get to know about them as you go through this blog.

println 


This method is use to print line of text and move cursor to the next line.

Following code is an example for how to use println method in Java


This is the out put of that program.



Let's print two lines using this method, just copy and paste the System.out.println.....line


Let's see the out put,


Now you can clearly see the cursor have moved to the next line after printing the line of text.


print


This method is also use to print line of text, but there is difference between the println and print methods print method does not move the cursor to the next line.

Following code is a example code for print method.






This is the out put,






Let's use print method twice,

This is the code,




And this is the out put,




No comments:

Post a Comment