answersLogoWhite

0


Best Answer

The escape character, the back slash: \, is the character that signals the following character is not what it normally means, i.e. as a reserved symbol, or as a new symbol.

The uses of the escape character include:

In Strings when " or ' is a required part of the string

String example1 = "She said,"Hello""; //the escape sequence signifies the " is actually //a " not the end of the String literal.

In Formatting Strings

\n means new line

\t means tab

i.e.

System.out.println("Hello\nHow are you?\tFine thank you.");

// Prints

// Hello

// How are you? [tab] Fine thank you.

And of course the really idiosyncratic one:

When the back slash is essential to a string, and you don't want it to be a escape character:

\\ means \

i.e.

System.out.println("\");

// Prints \

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Escape characters in Java are used in String literals when you need to enter something like a quotation mark, a slash, or a line return.

Java escape characters start with the backslash ( \ ). The escape character for the backslash (so your String will have a backslash in it) is simply "\".

If you put a " in your string, make sure that you remember that this will not close the String declaration, and will insert a quotation mark at that point.

To put a newline in a String, put \n. The text following it will be on a new line if it is displayed.

For example,

String newLine = "This is one\\a line\nThis is a "second" line";

System.out.println(newLine);

will output

This is one\a line

This is a "second" line

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is an escape character in Java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the ' ' called in java?

' ' would be the character for a space in Java.


Can a character in java apply in JOptionPane?

no!!


What is java string?

array of character data type which is terminated by null character


Which character signifies the beginning of an escape sequence?

The character is \


Character use only one byte why Java use two byte for character?

The number of bytes used by a character varies from language to language. Java uses a 16-bit (two-byte) character so that it can represent many non-Latin characters in the Unicode character set.


Why does java use unicode?

Transform character s into numbers (binary)


What is escape sequence?

Escape sequence is the question of I.T related technology Escape sequence is the question of C++ Language........ Please answer this question # defines the following character escape sequences: * \' - single quote, needed for character literals * \" - double quote, needed for string literals * \\ - backslash * \0 - Unicode character 0 * \a - Alert (character 7) * \b - Backspace (character 8) * \f - Form feed (character 12) * \n - New line (character 10) * \r - Carriage return (character 13) * \t - Horizontal tab (character 9) * \v - Vertical quote (character 11) * \uxxxx - Unicode escape sequence for character with hex value xxxx * \xn[n][n][n] - Unicode escape sequence for character with hex value nnnn (variable length version of \uxxxx) * \Uxxxxxxxx - Unicode escape sequence for character with hex value xxxxxxxx (for generating surrogates


What is (10.n).7?

Escape sequence is the question of I.T related technology Escape sequence is the question of C++ Language........ Please answer this question # defines the following character escape sequences: * \' - single quote, needed for character literals * \" - double quote, needed for string literals * \\ - backslash * \0 - Unicode character 0 * \a - Alert (character 7) * \b - Backspace (character 8) * \f - Form feed (character 12) * \n - New line (character 10) * \r - Carriage return (character 13) * \t - Horizontal tab (character 9) * \v - Vertical quote (character 11) * \uxxxx - Unicode escape sequence for character with hex value xxxx * \xn[n][n][n] - Unicode escape sequence for character with hex value nnnn (variable length version of \uxxxx) * \Uxxxxxxxx - Unicode escape sequence for character with hex value xxxxxxxx (for generating surrogates


Who played the role of jack harison in great escape?

No character by that name in "The Great Escape" (1963).


How do you store a character in a variable?

In Java a primitive data type called 'Char' is used to store a single character of text.Char myChar = "a";


In java is A string the same thing as a char?

No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.


What does it mean to have a string split in java?

To have a string split in Java means that a string array, containing substrings (can be delimited by elements of a specified string or Unicode character array), is returned.