Home Tutorial Java Corejava Java Escape Sequences

 
 

Share on Google+Share on Google+
Java Escape Sequences
Posted on: June 26, 2010 at 12:00 AM
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

Advertisement

Related Tags for Java Escape Sequences:


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.

Posted on: June 26, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com