Share on Google+Share on Google+

Java Escape Sequences

Advertisement
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

Advertisements

Posted on: June 26, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.