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
The \n escape sequence inserts a new line inside the string, so a single println statement produces two lines of output, showing how escape sequences can format output.