JavaK Your free source for Java Knowledge! AFRIKAANS  
  Homepage Contact Us Articles Projects Q and A Links  

Escape Characters

These special characters allow you to format strings in different ways. As your programming skills increase, you will find a time where you wish you had more control over the output of your programs. Escape characters is one way of manipulating the format of your program output, especially if you are doing console programming. Theses skills are also quite handy when you are doing report writing in your programs as they can be used to manipulate any string value.

First, we need a short list of these characters and then we will look at ways of using them. The following tables lists a few of the most commonly used escape characters in the Java programming language :

\tHorizontal tab
\fForm feed
\rCarriage Return
\"Double quote
\'Single quote
\###Octal character
\u####Unicode character

Assorted sample code for using escape characters.
                        The following statement will result in this output : The     big     bad     brown   bear!
                        The following statement will result in this output : "This string is quoted!"
                        System.out.println("\"This string is quoted!\"");
                        To output FOUR blank lines you will use the following statement :
                        To break apart an output string you will use the following statement :

The Author
This article about
Java Escape Characters was freely contributed by Ewald Horn to JavaK in the interest of all Java students. Please visit JavaK for more free Java articles. The author also maintains another website at