Printing Styles
In this lesson, we will look at different ways to print text to the screen in Java.
We'll cover the following...
In the last lesson, we used System.out.println
to print Hello World! to the screen. There are a couple of other ways to print text on the screen. Let’s take a look at each of them.
System.out.println
You can break the println
statement into print
and ln
(short for line). As apparent from the name, println
prints the complete text literal to the screen in the form of a line. The cursor moves to the next line after printing the text.
See an example below.
Press + to interact
class Introduction{public static void main(String args[]){System.out.println("My name is Tracy and I am 17 years old.");System.out.println("I am learning Java.");}}
Notice that after printing the text literal at line 5 ...