Home > Java > Javagetting Started > How to escape in java

How to escape in java

爱喝马黛茶的安东尼
Release: 2020-10-21 10:50:55
Original
16268 people have browsed it

Java method of escaping: Add "\" before the character that needs to be escaped to escape, so that the character has different semantics than when the character appears alone; for example: "\0 " represents a null character, "\t" represents a horizontal tab, "\n" represents a line feed, "\r" represents a carriage return, "\b" represents a backspace, and so on.

How to escape in java

1. Common escape characters

The English corresponding to the transfer character is escape character, escape string (Escape Sequence).

Add a slash "\" in front of the letters to represent common ASCII characters that cannot be displayed, called escape characters. Such as \0, \t, \n, etc., are called escape characters, because the following characters are not their original ASCII character meanings.

All escape characters and their corresponding meanings:

How to escape in java

Note: Distinguish between slash: "/" and backslash: "\" , not interchangeable here.

2. / slash and \backslash

① / slash, slash or also called forward slash (forward slash), originally a punctuation mark . It originated in ancient Rome and was used as a comma in the Middle Ages (at that time, the double slash // was used as a hyphen, and later evolved into the equal sign =).

(a) The slash in English is the most commonly used substitution character "or" to indicate selection, such as: Yes/No; and to avoid name conflicts, such as "" in the U.S. census table Assyrian/Chaldean/Syriac" is to avoid conflicts or ambiguities caused by different names of Syriana. It actually also means or.

(b) Arithmetic; It is called over in English, for example: 123/456, which is a fraction.

(c) Money representation. $50/- represents the upper limit of $50, and there is no more after it to prevent anyone from adding modifications.

(d) Representation of date.

② \ backslash, backslash, is mainly used in computers, and is also a reference to normal/slash. Operating systems (xNix), computer languages ​​(C/C, Perl), coding (part of Unicode), etc. all use it.

php Chinese website, a large number of free Java introductory tutorials, welcome to learn online!

The above is the detailed content of How to escape in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template