---
description: Three methods or functions are provided in the Java language to print the output. These methods depend on the method requirement and desired output in coding.
title: How to Print in Java
image: https://www.guru99.com/images/how-to-print-in-java.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

Printing in Java relies on three core methods from the PrintStream class that send formatted text to the console, support different cursor behaviors, accept multiple data types through overloaded signatures, and allow precise output control for any developer requirement.

* 🖨️ **print method:** System.out.print writes data on the same line, keeping the cursor in place for inline output.
* 📤 **println method:** System.out.println displays text and moves the cursor to the next line for clean separation.
* 🧾 **printf method:** System.out.printf applies format specifiers like %s, %d, and %f to control the output layout.
* ✅ **Overloaded signatures:** Each method accepts boolean, char, int, long, float, double, String, and Object types for flexibility.
* 🧪 **User input:** The Scanner class reads keyboard input through nextInt and prints the captured values with the print methods.

[ Read More ](javascript:void%280%29;) 

![How to Print in Java](https://www.guru99.com/images/how-to-print-in-java.png)

Java provides three core methods to send output to the console. Each method serves a distinct purpose and supports a range of data types through overloaded signatures, helping developers display information in the layout that best fits the program.

1. **Java print() method**: Data displays on the same line using the print statement in Java.
2. **Java println() method:** Output prints on the current line, and the cursor moves to the next line.
3. **Java printf() method**: Data displays with a particular format as per requirement.

## What Is the Java print() Method?

The Java print() method writes content to the console. It is an overloaded method of the Java PrintStream class and accepts a string as an input parameter.

After printing the input, the output cursor remains on the same line. The method works when no parameters are parsed. The print statement uses “\\n” to move to the next line.

**Syntax:**

The syntax shows how to operate the Java print statement.

System.out.print(String input_data);

System.out is a Java expression that creates an instance of the PrintStream class. It represents the standard output stream. You cannot use the PrintStream object directly.

* System: The System is a final class used in the “java.lang” package to display data.
* out: The “out” is an instance of the Java System class with a public member field. It is a type of PrintStream package to create objects internally.

**Example**

The given example shows the working procedure of the print() method.

class HelloCoder{
public static void main(String[] args) {
System.out.print("How to Print in Java! \n");
System.out.print("Hello Coder!");
System.out.print("Guru99!");
}
}

**Output:**

How to Print in Java!
HELLO CODER!
Guru99

## Why Use the Java println() Method?

The Java println() method is an advanced form of the print() method. It is used to show text on the console. It belongs to the PrintStream class through an overloaded method. This method works with a string parameter. After printing the given information, the cursor moves to the beginning of the next line.

**Syntax:**

The syntax shows how to operate the Java println statement.

System.out.println(String input_data);

println(): The PrintStream class used to display output on the console.

**Example:**

Let us see the example of the println() method.

public class HelloCoder {
	public static void main(String[] args) {
		System.out.println("How to Print in Java! ");
System.out.println("Hello Coder!");
System.out.println("Guru99!");
	}
}

**Output:**

How to Print in Java!
Hello Coder!
Guru99!

### Other Java Overloaded Methods in println()

Building on the println() method, the related print() method has the following overloaded signatures that accept different data types.

| **Overloaded Methods** | **Print Data Format**                                |
| ---------------------- | ---------------------------------------------------- |
| print(boolean b)       | This method shows the Boolean value                  |
| print(char c)          | A method displays the character                      |
| print(char\[\] s)      | It shows an array of characters                      |
| print(double d)        | It displays a double-precision floating-point number |
| print(float f)         | A method shows the floating-point number             |
| print(long l)          | It shows a long integer                              |
| print(int i)           | It shows an integer number                           |
| print(Object obj)      | This method operates on an object value              |
| print(String s)        | This method displays a string value                  |

### RELATED ARTICLES

* [Interface in Java with Example ](https://www.guru99.com/interface-in-java.html "Interface in Java with Example")
* [Java String contains(): Check if String contains Substring ](https://www.guru99.com/string-contains-method-java.html "Java String contains(): Check if String contains Substring")
* [How to Convert Char to String in Java (Examples) ](https://www.guru99.com/convert-char-string-java.html "How to Convert Char to String in Java (Examples)")
* [Pattern Programs in Java: Print Star, Pyramid & Number ](https://www.guru99.com/pattern-programs-in-java.html "Pattern Programs in Java: Print Star, Pyramid & Number")

## How the Java printf() Method Works

The Java printf() method displays a formatted string on the console with a specific format. It is a Java overloaded method of the PrintStream class to print values. The specifiers are displayed with formatted arguments in the method.

**Syntax:**

The syntax shows how to operate the printf() statement.

System.out.printf(String display_format, Object input_data);

**Example**

Let us see the example of the printf() method.

public class HelloCoder{
	public static void main(String[] args) {
		System.out.printf("'%s' %n","How to Print in Java!");
		System.out.printf("%S %n","Hello Coder!");
		System.out.printf("'%S' %n","Learning");
	}
}

**Output:**

'How to Print in Java!'
HELLO CODER!
'LEARNING'

## printf() Specifiers in Java

To control output formatting with System.out.printf, Java provides a set of specifiers that map each argument to the correct data type.

| **Specifier** | **Type**                              |
| ------------- | ------------------------------------- |
| %c            | Character value                       |
| %d            | Integer value                         |
| %f            | Floating-point number                 |
| %s            | String of characters                  |
| %%            | Prints or displays a percent (%) sign |
| %e            | Exponential floating-point value      |

**Example**

Let us see an example that combines the print, println, and printf methods in Java.

public class HelloCoder{
	public static void main(String[] args) {
		System.out.println("How to Print in Java!");
		System.out.printf("%S %n","Hello Coder!");
		System.out.print(" Guru99");
	}
}

**Output:**

How to Print in Java!
HELLO CODER! Guru99

## How to Print Using Entered Data in Java

Beyond fixed strings, Java can also print values entered by the user at runtime. The following steps show how to print entered data.

**Step 1)** Use the Java Scanner package to support user input data.

**Step 2)** A Scanner class or object operates to accept input from standard input. It enters through the keyboard.

**Step 3)** Create the [variable](https://www.guru99.com/java-variables.html) using the “Scanner(System.in)” method.

**Step 4)** Use the variable. nextInt() then reads all values from the keyboard.

**Step 5)** This method gets input data until it encounters a new line character (Enter).

**Step 6)** Finally, the input value prints the normal output using the System.out.print() function.

**Example**

Let us see the example of entering user input data and printing it in Java.

import java.util.Scanner;
public class HelloCoder {
    public static void main(String[] args) {
        Scanner reader_data = new Scanner(System.in);
        System.out.print("Enter a Value: ");
        int number_data = reader_data.nextInt();
        System.out.println("User entered: " + number_data);
        int add = number_data+number_data;
        System.out.println("Addition: " + add);
    }
}

**Output:**

Enter a Value: 21
User entered: 21
Addition: 42

## Other Java Overloaded Methods in print()

For reference, the print() method also supports the following overloaded signatures that accept different data types.

| **Overloaded Methods** | **Print Data Format**                                                                  |
| ---------------------- | -------------------------------------------------------------------------------------- |
| print(boolean b)       | This method shows the Boolean value                                                    |
| print(char c)          | This method shows the character                                                        |
| print(char\[\] s)      | This method displays an [array](https://www.guru99.com/java-arrays.html) of characters |
| print(double d)        | A method shows a double-precision floating-point number                                |
| print(float f)         | This method displays a floating-point number                                           |
| print(long l)          | This method shows a long integer                                                       |
| print(int i)           | This method shows an integer number                                                    |
| print(Object obj)      | It works for object value                                                              |
| print(String s)        | This method operates on and displays string value                                      |

## Comparing print Statements in Java

To choose between System.out.print and System.out.println, the table below highlights the primary distinctions between the two methods in Java.

| **Java println() statement**                                                                                                            | **Java print() statement**                                                                        |
| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| The cursor displays on the next line after displaying the output on the console. We can interpret ‘ln’ in ‘println’ as the ‘next line’. | The cursor appears on the same line after displaying the output on the console using the print(). |
| We can use the System.out.println(data) function to get the data and show the cursor on the next line.                                  | We can use the System.out.print(data) function to display the input data on the same line.        |

This code is editable. Click Run to Compile + Execute   

![]()

## FAQs

🖨️ What is the difference between print and println in Java?

System.out.print writes output on the same line and leaves the cursor in place. System.out.println writes the same output and then moves the cursor to a new line, which makes each statement appear on its own row.

🧾 When should I use printf instead of println in Java?

Use System.out.printf when the output needs a specific layout, fixed width, or numeric precision. Specifiers such as %s, %d, and %.2f format strings and numbers, while println is better suited for simple one-line text output.

📤 How do I print variables and text together in Java?

Use the plus operator to join a string with a variable inside System.out.println, for example System.out.println(“Total: ” + total). For richer formatting, use System.out.printf with specifiers like %s and %d to insert variable values into a template.

🤖 Can AI tools auto-format Java printf strings?

Yes, modern AI assistants in IDEs can suggest correct printf format strings, fix mismatched specifiers, and align arguments with their types. Developers should still review the suggested format to confirm width, precision, and locale behavior match the intended output.

🧪 Do AI code suggestions favor Java logging over System.out.print?

In production code, AI assistants often recommend a logging framework such as SLF4J or java.util.logging instead of System.out.print. Logging supports levels, formatting, and output targets, while print methods remain useful for quick examples and small console programs.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/how-to-print-in-java.png","url":"https://www.guru99.com/images/how-to-print-in-java.png","width":"700","height":"250","caption":"How to Print in Java","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/how-to-print-in-java.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/java-tutorials","name":"Java Tutorials"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/how-to-print-in-java.html","name":"How to Print in Java"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/how-to-print-in-java.html#webpage","url":"https://www.guru99.com/how-to-print-in-java.html","name":"How to Print in Java","dateModified":"2026-06-26T11:21:51+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/how-to-print-in-java.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/how-to-print-in-java.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/james","name":"James Hartman","description":"I am James Hartman, a seasoned professional in Oracle Certified Java Professional tutorials, specializing in crafting comprehensive guides to help you excel in your Java certification journey.","url":"https://www.guru99.com/author/james","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/james-hartman-author-v2-120x120.png","url":"https://www.guru99.com/images/james-hartman-author-v2-120x120.png","caption":"James Hartman","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"Java Tutorials","headline":"How to Print in Java","description":"Three methods or functions are provided in the Java language to print the output. These methods depend on the method requirement and desired output in coding.","keywords":"java","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/james","name":"James Hartman"},"dateModified":"2026-06-26T11:21:51+05:30","image":{"@id":"https://www.guru99.com/images/how-to-print-in-java.png"},"copyrightYear":"2026","name":"How to Print in Java","subjectOf":[{"@type":"HowTo","name":"How to print in Java with Examples","description":"Three methods or functions are provided in the Java language to print the output. These methods depend on the method requirement and desired output in coding.","step":[{"@type":"HowToStep","name":"Method 1: Java print() method","text":"Java print method works for printing content to the console. It belongs to an overloaded method of the java PrintStream class. It takes a string as an input parameter.","url":"https://www.guru99.com/how-to-print-in-java.html#step1"},{"@type":"HowToStep","name":"Method 2: Java println() method","text":"Java println method is an advanced form of the print() method. It is used to show text on the console. It belongs to the PrintStream class through the overloaded method. this method is worked with a string parameter. After printing the given information, the cursor is moved to the beginning of the next line.","url":"https://www.guru99.com/how-to-print-in-java.html#step2"},{"@type":"HowToStep","name":"Method 3: Java printf() method","text":"Java printf method displays the formatted string on the console with the specific format. It is a java-overloaded method of the PrintStream class to print values. The specifiers are displayed with formatted arguments in the method.","url":"https://www.guru99.com/how-to-print-in-java.html#step3"}]},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is the difference between print and println in Java?","acceptedAnswer":{"@type":"Answer","text":"System.out.print writes output on the same line and leaves the cursor in place. System.out.println writes the same output and then moves the cursor to a new line, which makes each statement appear on its own row."}},{"@type":"Question","name":"When should I use printf instead of println in Java?","acceptedAnswer":{"@type":"Answer","text":"Use System.out.printf when the output needs a specific layout, fixed width, or numeric precision. Specifiers such as %s, %d, and %.2f format strings and numbers, while println is better suited for simple one-line text output."}},{"@type":"Question","name":"How do I print variables and text together in Java?","acceptedAnswer":{"@type":"Answer","text":"Use the plus operator to join a string with a variable inside System.out.println, for example System.out.println(\"Total: \" + total). For richer formatting, use System.out.printf with specifiers like %s and %d to insert variable values into a template."}},{"@type":"Question","name":"Can AI tools auto-format Java printf strings?","acceptedAnswer":{"@type":"Answer","text":"Yes, modern AI assistants in IDEs can suggest correct printf format strings, fix mismatched specifiers, and align arguments with their types. Developers should still review the suggested format to confirm width, precision, and locale behavior match the intended output."}},{"@type":"Question","name":"Do AI code suggestions favor Java logging over System.out.print?","acceptedAnswer":{"@type":"Answer","text":"In production code, AI assistants often recommend a logging framework such as SLF4J or java.util.logging instead of System.out.print. Logging supports levels, formatting, and output targets, while print methods remain useful for quick examples and small console programs."}}]}],"@id":"https://www.guru99.com/how-to-print-in-java.html#schema-277214","isPartOf":{"@id":"https://www.guru99.com/how-to-print-in-java.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/how-to-print-in-java.html#webpage"}}]}
```
