Close

Java String Formatting - How to terminate line using printf?

Java String Formatting Java 

This example shows how to terminate line with String#printf()

We can use %n for line termination.

package com.logicbig.example.string;

public class StringFormatLineTerminate {

public static void main(String[] args) {
System.out.printf("I%nlike%nmango%n");
}
}

Output

I
like
mango




See Also