1. Overview
| Basic type |
Size |
Minimum value |
Maximum Value |
Package Type |
Defining flags |
| Boolean |
~ |
~ |
~ |
Boolean |
~ |
| Char |
16bits |
Unicode0 |
Unicode2^16-1 |
Character |
~ |
| Byte |
8bits |
-128 |
+127 |
Byte |
~ |
| Short |
16bits |
-2^15 |
+2^15-1 |
Short |
~ |
| Int |
32bits |
-2^31 |
+2^31-1 |
Integer |
~ |
| Long |
64bits |
-2^63 |
+2^63-1 |
Long |
L |
| Float |
32bits |
IEEE754 |
IEEE754 |
Float |
F |
| Double |
64bits |
IEEE754 |
IEEE754 |
Double |
D |
| void |
~ |
~ |
~ |
Void |
~ |
2. Member variable default value
| Basic type |
Default value |
| Boolean |
False |
| Char |
' \u0000 ' (null) |
| Byte |
0 |
| Short |
0 |
| Int |
0 |
| Long |
0L |
| Float |
0.0f |
| Double |
0.0d |
3. High-precision Digital
- BigInteger supports arbitrary-precision integers
- BigDecimal support for arbitrary-precision fixed-point numbers
Packagecn.lz.base;ImportJava.math.BigDecimal;ImportJava.math.BigInteger;/*** * High-precision Digital *@authorlzzz **/ Public classJ17100802 { Public Static voidMain (string[] args) {BigInteger A1=NewBigInteger ("19181716151413121110987654321"); BigInteger A2=NewBigInteger ("12345678910111213141516171819"); //additionSystem.out.println (A1.add (A2));//31527395061524334252503826140//multiplicationSystem.out.println (a1.multiply (A2));//236811308550240594910066199325923006903586430678413779899// int a3 = 12345678910111213141516171819; /** Exception in thread "main" java.lang.Error:Unresolved compilation problem: * The literal 12345678 910111213141516171819 of type int is out of range*/BigDecimal B1=NewBigDecimal ("12345678910111213141516171819.12345678910111213141516171819"); BigDecimal B2=NewBigDecimal ("12345678910111213141516171819.12345678910111213141516171819"); //multiplicationSystem.out.println (b1.multiply (B2));//152415787751564791571474464065423486394871076136159258042.2627449915719520852517428216262375170639839780304729768761 }}
Java Basic data types