Understanding how to create and manipulate objects from the ground up in java-1.8 (2)
Next, let's continue with the topic about object creation and operation.
(2) Basic type creation and operation
As mentioned in the above storage, the new object is usually placed in the heap, and the direct relationship between the object and the variable is placed in the stack. In fact, there are other things in the stack, that is, the value stored by the basic type, this makes the operation faster.
Below are some basic types of information:
|
Simple Type |
Boolean |
Byte |
Char |
Short |
Int |
Long |
Float |
Double |
Void |
|
Binary digits |
1 |
8 |
16 |
16 |
32 |
64 |
32 |
64 |
-- |
|
Package class |
Boolean |
Byte |
Character |
Short |
Integer |
Long |
Float |
Double |
Void |
The basic types all have corresponding wrappers:
int a = 10000;Integer b = new Integer(10000);
High precision type:
BigDecimal c;BigInteger d;
BigDecimal supports fixed points of any length, most of which are used for currency calculation.
BigInteger supports the calculation of integer numbers of any length.
(3) create and initialize Arrays
Like c and c ++, java also supports arrays.
Arrays in c and c ++ can cause very large memory management problems. Therefore, java arrays must be initialized. If the number of arrays exceeds the storage limit, an exception occurs. Efficiency is used for security.
The array is detailed in the following sections.
This section briefly introduces how to create basic types and arrays.
This chapter is here. Thank you.
-----------------------------------