Introduction
In Java, print and println are methods of the System.out class used to display output on the console. The key difference is that print outputs text without a newline, while println appends a newline after printing the text. This means print keeps the cursor on the same line, whereas println moves it to the next line.

In this article, we will learn their differences with examples.
What is `print` in Java?
The `print ` method in Java is used to display text or data on the console without moving the cursor to the next line. It is part of the `System` class, which is included in the `java.lang` package. This means you don’t need to import anything extra to use it. The `print ` method simply outputs whatever you pass to it & keeps the cursor on the same line, ready for the next output.
Syntax of `print`
The syntax for the `print` method is very easy:
System.print(data);
Here, `data` can be a string, number, variable, or even an expression. The method will convert the data into a string & display it on the console.
Example of `print`
Let’s look at a simple example to understand how `print` works:
public class PrintExample {
public static void main(String[] args) {
System.out.print("Hello, ");
System.out.print("World!");
}
}
In this Code:
1. We start by creating a class named `PrintExample`.
2. Inside the `main` method, we use `System.out.print("Hello, ");` to display the text "Hello, " on the console. Notice that the cursor stays on the same line after this output.
3. Next, we use `System.out.print("World!");` to display "World!" on the same line as "Hello, ".
When you run this program, the output will look like this:
Hello, World!
As you can see, both `print ` statements combine their output on a single line. This is the key behavior of the `print` method.
When to Use `print`
- Use `print ` when you want to display multiple pieces of data on the same line.
- It’s useful for creating formatted output or combining text with variables without adding unnecessary line breaks.
For example, if you want to display a user’s name & age on the same line, you can use `print` like this:
String name = "Alice";
int age = 25;
System.out.print("Name: " + name + ", ");
System.out.print("Age: " + age);
Output:
Name: Alice, Age: 25
This makes your output cleaner & easier to read.