JAVA Char Type

Source: Internet
Author: User

The char type represents a single character type, and any data enclosed in single quotation marks is a representation of a character. A character can have only one character.

Note: escape sequences for special characters: escape characters

An overview of escape characters:

Special characters use "\" to convert it to the output of the character itself, and the character "\" is called a transfer character.

Requirements: Use the output statement to print out quoted information such as output.

SYSTEM.OUT.PRINTLN ("Teacher said" Java is fun "), compilation does not pass properly. syntax has errors, the compiler reads the second quotation mark is considered the end of the string, the remaining do not know how to handle. How to solve this problem: use escape characters in Java to represent special characters. An escape character begins with a backslash (\).

problem: If you want to print a quoted string, you can use the backslash (\) followed by the character, which is the escape character.

Escape character

Name

Unicode

\b

Backspace (BACKSPACE)

\u0008

\ t

Tab ( Tab keyboard)

\u0009

\ n

linefeed (line wrapping)

\u000a

\ r

Carriage Return (carriage return)

\u000d

\\

Backslash (back slash)

\u005c

\‘

Single Quote (single quotation mark)

\u0027

\"

Double Quote (double quotes)

\u0022

\ r means accept keyboard input, equivalent to press ENTER.

\ n indicates a line break.

\ t tab, equivalent to table key

\b Backspace key, equivalent to back Space

\ ' Single quotation mark

\ ' double quotes

\ \ represents a diagonal cross

Solve the above question: System. out. println ("Teacher Said\" Java is fun\ "");

Note: The line break is another line, the carriage return is the beginning of a line, so we usually write a file carriage return should be exactly called carriage return line break

JAVA Char Type

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.