02 data types

------------ ------------ restore content begins

The basic data types

Integer: byte (. 1) Short (2) int (. 4) Long (. 8)

Decimal: a float (. 4) Double (. 8)    

Boolean: boolean: false to true

Character: char

 

variable:

1. Data type variable name = variable value ;

2. = is the assignment of meaning to indicate the presence of the value of the variable on the left to the right. It is the lowest priority.

3. Each line program written for future use ; numerals

4. Variables must be declared before you can use later. Statement declared only once, assignment multiple times. Temporary variable must be initialized (first assignment) to use

5. When = type of inconsistency on both sides need to first turn to the same type. Type conversion into automatic conversion with a cast.

6. automatically from low to high conversion. From the high and low is cast.

Strong transfer risk, need to be cautious:

1 , overflow    2 , accuracy is lost

 

char: length is 1 , the single quotation marks. char can be used or coded value assignment. java characters using a Unicode encoding, a character 2 bytes

 

 

Reference data types String

 

Constant: the amount of content can not change. It must be initialized only 1 times.

 

Identifier naming rules:

 

  1. Only contain numbers, letters, underscores _ , dollar sign $ , we can not start with a number. 2
  2. Not be a keyword. See name known meaning.
  3. Speaking from the rule, you can use the Chinese name, but certainly not to use Chinese.

 

Notes: 3 kinds:   

 

 // a single line comment        ctrl + /

 

/   Multi-line comments       /

 

/ *   Documentation comment, written in the general class with the above methods used to generate doc file     * /

 

End ------------ ------------ restore content

Guess you like

Origin www.cnblogs.com/beimo/p/11862532.html