Java note Seventh data type first understanding (bottom, after containing the loop output A-Z)

Source: Internet
Author: User

#日常唠叨1 # Why hasn't it been updated for so long? Because the small stars of the school without advance notice of the situation carried out military training, no time to play blog. It is now September 1 after the decision to update every Sunday, one week more

#日常唠叨2 # Someone asked what is the use of these data types? Hehe, you'll know when you get to the variable.

In addition to the two basic data types that represent numbers in Java, there are two basic data types, one of which are Boolean, that represent numbers. The Boolean type is divided into only one type (which can also be understood as no subdivision):boolean. It has a value of only two:false (0) and true (1). However, this does not mean that it occupies a single byte (in fact, the Boolean occupies one bit, but the specific few bytes are still controversial).

Data type Occupy Storage space Value
Boolean A

True (1)

False (0)

Boolean is typically used for process conditions in Process Control statements (which will be written later) and is not used in many other places.

In addition, the last basic data type-the character type and the Boolean type-can be represented as a number, and is also divided into one type (as can be understood as no subdivision): char (some may have studied Java, what string is it?). String strings are actually reference data types, which are later written). The character type uses Unicode encoding, so it can represent all human languages in the world, not just in English. Unicode encoding consumes only 2 bytes, but has 65,535 human language characters (but only one char character when used).

Data type Occupy Storage space Table Count Range
Char 2 bytes 0~65535

In addition, in the Java language, characters that are caused by single quotation marks (' ') are a char character (a double quote "" denotes a string string constant). Char can be represented as a number when the char character can be transformed directly into an integer value (10) based on its Unicode value (16 binary), while the integer value between 0~65535 can also be coerced into a Unicode value (specifically written later).

The Java language also supports the use of escape characters (\) to convert subsequent characters into other meanings, and here is a common transfer table:

Escape character Meaning Unicode value
\b Backspace \u0008
\ n Line break \u000a
\ r Carriage return character \u000d
\ t Tabs \u0009
\" Double quote literal \u0022
\‘ Single quote literal \u0027
\\ Backslash literal \u005c

(Note: The recommended escape character is used in string string "" and may be problematic in char)

In addition to the coding, here is a picture, you see yourself (arrows indicate on the basis of the previous development):

about char to int, I put a set of code here, you copy this set of code to the previous write HelloWorld

 Public Static void main (String [] args) {}
Main Method

And then run through the Javac, Java command:

char c = ' a '; for (int i = 1; i <=; i++) {    Char temp = (char) (c-1+i);    System.out.print (temp+ "\ t");    if (i% 4 = = 0) {        System.out.print ("\ r \ n");}    }

(The notepad++ editor opens the full code preview diagram:

How the code runs and the resulting diagram:

(Note: Do not deliberately to read, will be written later)

Java note Seventh data type first understanding (bottom, after containing the loop output A-Z)

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.