Please explain the meaning of the characters ' \ ' in Java, what is the role?

Source: Internet
Author: User

/*
* 2, please explain the meaning of the characters ' \ ' in Java, what is the role?
*
Answer
* In Java the backslash ' \ ' represents the meaning of the escape character, which is a marker
*
* When the compiler reads this tag, it knows that the next character is not an ordinary character, but a translated character.
* It will operate based on the meaning of the escaped character, rather than using the original character directly.
*
* When encountering some special characters used in Java syntax, to output as-is, you need to precede these special characters with a backslash
* such as the backslash itself, single quotation marks, double quotes, parentheses, etc., because the syntax is already occupied, so to want the output as is, only in front of the plus a backslash.
* For example E:\123.txt path for Java to read need to add a backslash before \ Translate E:\\123.txt
*
*/

Please explain the meaning of the characters ' \ ' in Java, what is the role?

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.