Introduction to Java escape characters and basic data types

Source: Internet
Author: User

Escape character:

Escape characters are used to convert characters that are treated as code and characters that are not recognized, converting these characters to characters that can be printed out.

The following are the functions of some escape characters:

1.\n ( carriage return ): For carriage return, without escape character enter is not recognized

2.\t ( watchmaking ): A tab is a supplement of eight spaces, such as ABC, which adds five spaces to the back of the character, since the preceding three characters are counted, and if the characters are longer than eight, for example Abcdefghijk , and then fill the space with more than the number, like the front end of the Ijk more than three add five spaces after these three.

3.\r ( fallback ): is used to fall back to the beginning of the current line

4.\a ( warning ): Audible alarm on dos interface, but now it's useless.

5.\ " ( double quotation marks ): Used to display double quotes, because in Java directly hit " " number is used as a code symbol.

6.\ ' ( single quotation mark ): Used to display single quotes, because in Java directly hit ' ' number is used as a code symbol.

7.\\ ( slash ): Used to display single quotation marks, because in Java , a direct call is a code symbol that is treated as a comment.

Basic data type:

  1 bytes 8

The smallest unit in the computer is a bit, which is the 0 1 Span style= "font-family: ' The song Body '; > 1 =8 bit, 1024 =1k 1024k=1m 1024m=1g Span style= "font-family: ' The song Body '; >, 1024g=1t ... and so on.

The only binary that can be identified in a computer is the binary, which is converted by a character descriptor.

Binary :0 1

Octal :0 1 2 3 4 5 6 7

decimal:0 1 2 3 4 5 5 6 7 8

16 binary: 0. 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Data types can be stored in size:

1.byte:1 bytes =8 bit 127~-128

2.short:2 bytes =16 bit 32767~-32768

3.int:4 bytes =32 bit 2147483647~-2147483648

4.long:8 bytes =64 bit

9223372036854775807~-0223372036854775808

5.float:4 bytes =32 bit

6.double:8 bytes =64 bit

7.boolean:1 bytes =8 bit ( only one bit can actually be used ) true0 False1

8.char:2 bytes =16 bit 0~65535

Char character conversion principle:

The char type is used to store a single character, occupying A memory space of up to five bits, because only binary is recognized in the computer, and Char is given inJava type, you need to pass the value of the Unicode characters are converted into a single character. For example, a char type is assigned a value of zero , and then the result of the printout is a single character a.


This article is from the "12831981" blog, please be sure to keep this source http://12841981.blog.51cto.com/12831981/1955639

Introduction to Java escape characters and basic data types

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.