Characters and escape sequences in Java

In this post of java for zombie’s edition we will study the characters that can appear in a Java program. We now know the basics of java and how to create a first basic program, now let’s see the characters and escape sequences in java you can use to build more complex programs.

Hence characters appear in a Java program to form constants, variables, expressions, etc., are:
The letters uppercase and lowercase letters from A (a) to Z (z) of international alphabets

(Numbers (0, 1, 2 …)

The characters ‘_’ ‘$’ and any Unicode character above 00C0.

Special characters and following punctuation:

+ – * / =% & #! ? ^ ” ‘~ \ | <> () [] {}:; . ,

Blanks: Blanks are called to the following characters: space, tab, line break. Their work is the same as a blank: separating between elements of a program.
For example, we can write the main method without using blanks, of the form:

public static void main (String [] args) {System.out.println ( “Hello World !!!”);}
Although there is much clearer if we introduce spaces:

public static void main (String [] args) {

   System.out.println ("Hello World!!!");


 Charactors and escape sequences in java

Escape Sequences:

An escape sequence is a backslash followed by a letter or a combination of digits.

so an escape sequence always represents a single character but is written with two or more characters.
It is used to perform actions such as line break or to print unprintable characters

Description of image sequences in java:

Escape Sequence Description
\ n Go to the top of the next line
\ b Recoil
\ t horizontal tab
\ r Top of the line
\ “ Quotation marks
\ ‘ Simple comma
\\ backslash
\ f Form feed in text

and if we want to put quotes in a sentence we cannot use quotes within quotes for adding quotes we will have to use the escape sequence, \”, on the interior quotes

public class newTest {

public static void main(String args[]) {

System.out.println("She came over and said \"Hello!\" to me.");



therefore the output will look like this
Output: She came over and said “Hello!” to me. 

Next article in the series will be  “Identifiers, Reserved words and Comments is Java.”
Make sure you follow us on Twitter or Facebook to get an update about upcoming posts in Java for zombies series.



Leave a reply