"Thinking in Java" learning notes (2) - all things are object

xiaoxiao2021-03-06  84

"Thinking in Java" learning notes (2)

---- All things are all objects

Author: Lonely Firefly

The relationship between the object and the Reference is better than the relationship between the TV and the remote control, as long as there is a remote control in your hand, you can manipulate the TV. If you want to walk in the room, keep control over TV, just take a remote control with you, don't have to carry a heavy TV.

Six places can be stored in:

1. Registers: Located inside the processor, the fastest storage site, the programmer can't touch, nor does it feel it in the program. The compiler will properly allocate it according to your own needs.

2. Stack: Located in the RAM, the speed is second only to the register, and must be able to grasp the actual size and survival time of the stored data. The Reference can be stored in the Stack, but the general object cannot be placed thereon.

3. Heap: Also in RAM, slower than Stack, used to place all Java objects.

4. Static Storage Space: Also in the RAM, the data that has been existing during execution is stored. You can use keyword static to set specific members within the object to static, but the Java object itself is unable to place it.

5. Constant Storage: You can put it in the ROM and store constants.

6. Non-RAM storage: Even if the program is not executed, the data can continue to exist. Such as: streamed objects and persistent objects. Java provides so-called Lightweight Persistence.

The space size of each basic type in Java is fixed:

Basic type

size

Minimum

Maximum

Default

Outer

Boolean

-

-

-

False

Boolean

charr

16-bit

Unicode 0

Unicode 216-1

'/ U0000' (NULL)

Character

Byte

8-bit

-128

127

(Byte) 0

Byte

Short

16-bit

-215

215-1

(Short) 0

Short

int

32-bit

-231

231-1

0

Integer

Long

64-bit

-263

263-1

0L

Long

Float

32-bit

IEEE754

IEEE754

0.0F

Float

Double

64-bit

IEEE754

IEEE754

0.0D

Double

Void

-

-

-

Void

Boolean type has not been explicitly defined whose value can only be constant value true or false.

Java guarantees the initial value for this variable only when the variable identity is a "member in Class".

Two Classes: Biginteger (providing an integer supports arbitrary precision) and BigDecimal (providing any precision of any precision).

The price that ensures that programmers to access the array visits cannot be paid by: Each array has an additional point space and checks the array index value on the execution period.

The ability to "obscure variables in larger living space" in C / C , Java is not available.

Java.lang will be automatically included in each Java program file.

Data within the direct operation of the object can cause confusion, and also a good object-oriented design method has lanes.

转载请注明原文地址:https://www.9cbs.com/read-93373.html

New Post(0)