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

Get our latest blog posts delivered to your inbox

Subscribe and get popular blog posts about software testing industry.

Rajkumar

Leave a Comment

Share via
Copy link
Powered by Social Snap