Escape Sequences in Java


☞There are some non-graphic characters, which are used as commands to direct the cursor while printing.

☞These characters are frequently used in programming , and are called escape sequences.

☞An escape sequence character begin with a backslash( \ ) and it is followed by one or more characters.

Example :

class Escape{
      public static void main(String args[]){ 

               String name="Avlokan Mohan";
               System.out.println("Name :\t"+name);
               System.out.println("Name :"+"\'"+name+"\'");
               System.out.println("Name :"+"\""+name+"\"");	
               System.out.println("Name :\n"+name);

      }
}

Output

Name :	     Avlokan Mohan
Name :'Avlokan Mohan'
Name :"Avlokan Mohan"
Name :
Avlokan Mohan