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
Following code is an example for how to use println method in Java
This is the out put of that program.
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.
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.
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