3. Java Basic type
650) this.width=650; "style=" width:707px;height:232px; "title=" 01.png "alt=" wkiol1vlbhgaagnpaahz_1jnfq0036.jpg "src = "Http://s3.51cto.com/wyfs02/M02/6C/81/wKioL1VLBhGAagnPAAHZ_1jnFQ0036.jpg" width= "735" height= "228"/> Frequently used types are as follows (5 types):
1) Int: integral type
1.1) the direct amount of a number is of type int (the so-called direct quantity is the value that is written directly, such as int a = 10000;)
1.2) Two int operation, the result is an int type, and the decimal bit is unconditionally discarded ( such as: int A=5/3; result is a=1)
1.3) Range -2^31 ~ ~ 2^31-1, overrun may occur in the range, you need to avoid
2) Long: Length-integer
2.1) long direct quantity, after integer plus L or l
2.2) Value range -2^63 ~ ~ 2^63-1
2.2) JDK provides a way to get the current system time: System.currenttimemillis (), gets the time from 1970.1.1 0 o'clock to now, returns a long type value
3) Double: floating-point, double-precision
3.1) The direct amount of decimals is double by default (for example: double d = 1.023; ), if you use float to represent decimals, you need to add F or F later
3.2) scientific notation means: 3.14E2, 3.14e2,3.14e-2, etc., such as: 3.14E2 means 3.14 times 10 2
3.2) With rounding error, use with caution when precise operation (for example: double D = 3.0-2.9; after calculation d = 0.10000000000000009;)
4) Char: Character type
4.1) char is actually a 16-bit unsigned integer with a value range of 0~~65535, so char can directly define integers (such as: char C = 123;)
4.2) Char defines the variable when the value is placed in the single quote ' ', is characters in Unicode encoded format (e.g. char c = ' Medium ',)
4.3) when defining a char variable, you can take an escape character (e.g. char C1 = ' \u0041 '; char c2 = ' \ n ')
escape character |
meaning |
' \ n ' |
represents a carriage return |
' \ r ' |
represents a newline character |
' \ \ ' |
represents a backslash (\) |
' \ ' |
denotes single quotation mark (') |
‘\"‘ |
Represents double quotation marks (") |
5) Boolean: Boolean, 1-byte
5.1) Boolean direct amount, only true and false,true indicate that the condition is set, false indicates not valid
(For example: boolean flag = true;)
4. Conversion of data types
Represents the range of values from small to lower as shown below
650) this.width=650; "style=" width:422px;height:88px; "title=" 02.png "alt=" Wkiol1vlbocc1xhaaacd1ecdv9i355.jpg "src= "Http://s3.51cto.com/wyfs02/M02/6C/81/wKioL1VLBoCC1xhAAACD1EcDV9I355.jpg" width= "528" height= "/>"
1) automatic type conversion: From small type to large type
2) Forced type conversions: from large types to small types, strong turns can occur: loss of precision, overflow
Case 2:
650) this.width=650; "title=" 03.png "alt=" wkiol1vlbqjx3f2paag_bazmmj8861.jpg "src=" http://s3.51cto.com/wyfs02/M01/ 6c/81/wkiol1vlbqjx3f2paag_bazmmj8861.jpg "/>
This article is from "Forever Young" blog, please be sure to keep this source http://kingkongzhao.blog.51cto.com/6319491/1643837
Java Basic Learning Notes--4 (Basic data type)