Print In Java | Java Tutorial

We use print in java to output required text directly to the console of IDE. Let’s see the syntax of print in java and the difference between print and println in Java.

Syntax of Print in Java:

Simple print statement:

A simple print statement with a new line:

What is the difference between print and println methods in Java?

The basic difference between the print() and println() methods in Java are when using println(), the cursor in the output will be shown in the next line after printing the required output on the screen whereas when using print() method, the cursor will be shown in the same line after printing the required output on the screen.

Sample Program:

Simple print program – Print text and stay in the same line

Simple print program – Print text and go to a new line

Declaring a variable named website and print some text and go to a new line

Must Read: Java Tutorial

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

Leave a Comment

Share via
Copy link
Powered by Social Snap