Double quotation marks in Java character escape strings

Source: Internet
Author: User

When creating or displaying a string, its text must be enclosed in double quotation marks to indicate the start and end of the string. These double quotation marks are not displayed, which raises a good question: What should I do if I want to display double quotation marks?

To display double quotation marks, Java creates a special encoding \ ", which can be placed in a string. When this encoding is encountered in a string, replace it with double quotation marks. For example, see the following example:

System. Out. println ("Jane Campion directed \" the piano \ "in 1993 .");

This sectionCodeThe following content is displayed:

Jane Campion directed "The Piano" in 1993.

You can use this method to insert multiple special characters into the string. These special characters are listed below. Note that each character is preceded by a backslash.

Special characters

Display

\'

Single quotes

\"

Double quotation marks

\/

Backslash

\ T

Tab

\ B

Return character

\ R

Carriage Return

\ F

Paper break

\ N

Line Break

A line break is used to display text after a line break at the beginning of the next line. See the following example:

System. Out. println ("Music by \ nmichael Nyman ");

This statement will display the following content:

Music

Michael Nyman

Address character: \=> \\

\\=>\\\\

http://blog.csdn.net/lsd123/article/details/2974200

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.