Home Tutorial Java Corejava Java Escape Sequences

 
 

Java Escape Sequences
Posted on: June 26, 2010 at 12:00 AM
This tutorial demonstrate the java escape sequence with example.

Description:

In java any character that is preceded by a backslash (\) is known as escape sequence, which has special meaning for the compiler. Following are list of Java escape sequences

Escape Sequence Meaning
\t tab
\n new line
\r carriage return
\' single quote
\" double quote
\\ backslash

Code:

public class ExcapeSeq {
  public static void main(String args[]) {
    System.out.println("Name\tRollNo\tAddress");
    System.out.println("Name\nRollNo\nAddress");
    System.out.println("Name\rRollNo\rAddress");
    System.out.println("Name\'RollNo\'Address");
    System.out.println("Name\"RollNo\"Address");
    System.out.println("Name\\RollNo\\Address");
  }
}

Output:

Download this code

Related Tags for Java Escape Sequences:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.