Print Text with Newline Escape Sequence

This program demonstrates the newline escape sequence.

Problem Statement

Write a Java program that prints text using the newline escape sequence.

Source Code

1 public class NewlineEscape {
2 public static void main(String[] args) {
3 System.out.println("Welcome to Eduinq\nLearn Java Easily");
4 }
5 }

Program Output

Welcome to Eduinq
Learn Java Easily

Explanation

\n Inserts a new line. Prints two lines using one println statement. Conclusion: Shows how escape sequences can format output.

Quick Links to Explore