How to print something on the screen

The word “print” does not mean the printing using a tangible printer. We use that word to tell that we are displaying something on the screen.

It is easy in JAVA.

System.out.print(“Hello Java”);


System.out.println(“Hello Java”);

Let’s identify the important features of the two statements given above.

  1. The “S” in the word “System” should be capital.
  2. Whatever given inside the brackets will be printed.
  3. If you want to print a string, you need to use inverted commas.
  4. If you want to print a predefined variable, just use the variable name.
  5. Use “print”(first statement) to keep the cursor in the same line.
  6. Use “println”(second statement) to move the cursor to the next line.

Important :

Whatever you type in java, you need to type inside the main class.


More zoomed picture is given below.


Can you understand what happened?

First “Hello Java” is printed. Since we used just the “print”, the cursor is not moved down. Then again “Hello Java” is printed without a space even. That is why you get “JavaHello” word in the middle.

Let’s print it in a polite manner.


Likewise you can print a predefined variable also.


I made 2 variables , an integer and a string.

Then I printed them.

Now we’ll learn how to concatenate inside a print statement.

System.out.println(“I am  “+ age + ” years old. \n My school is ” + school);


Concatenation in JAVA is done by the plus (+) sign.

The “\n” takes the cursor to the next line. So the cursor will be moved to the next line in the middle of the print statement.

Just look at the output now.


So that’s it for this section. See you soon in the next section.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s