Searching...
Wednesday, 1 May 2013

Java Escape sequences Examples

01:53

Java Escape sequences Examples

Java Escape sequences

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

Example

Here is one printing example which is using escape sequences.

package com.http;

public class JavaEscapes {

    public JavaEscapes() {
    }
    public static void main(String[] args) {
            System.out.println("Start\tProcess\tStop");
            System.out.println("Start\nProcess\nStop");
            System.out.println("Start\rProcess\rStop");
            System.out.println("Start\'Process\'Stop");
            System.out.println("Start\"Process\"Stop");
            System.out.println("Start\\Process\\Stop");
    }

}

Output

Start Process Stop
Start
Process
Stop
Start
Process
Stop
Start'Process'Stop
Start"Process"Stop
Start\Process\Stop

0 comments: