Chapter II Everything is an object
2.1 Reference Action Object
For security purposes, you create a reference and initialize it.
String S=new string ("asdf");
The new operation creates a novel string object, s reference to this object
2.2 must be created by you all objects
2.2.1 6 Data storage areas
Register Device:Within the CPU, resources are limited by the compiler on demand, the fastest speed.
Stack:In Universal RAM, the stack pointer moves down to allocate new memory, while moving up frees up memory, but the Java compiler must know the size and lifecycle of all of the data, the speed behind the registers, the base data type and the reference stored here.
Heap:Located in the Ram area for all Java objects, the compiler does not have to know the data size and lifecycle
Static storage:In the Ram area, static storage holds the data that the program has been running
Constant storage:Data content will never change
Non-RAM storage:Live completely outside the program, not under any control of the program
9 Basic types of 2.2.2
| Basic type |
Size |
Minimum value |
Maximum Value |
Wrapper type |
| Boolean |
- |
- |
- |
Boolean |
| Char |
16-bit |
Unicode0 |
Unicode 216-1
|
Character |
| Byte |
8-bit |
-128 |
+127 |
Byte |
| ShoRT |
16-bit |
-215 |
+215-1 |
Short |
| Int |
32-bit |
-231 |
+231-1 |
Integer |
| Long |
64-bit |
-263 |
+263-1 |
LOng |
| Float |
32-bit |
IEEE754 |
IEEE7 |
Float |
| Double |
64-bit |
IEEE754 |
IEEE7 |
Double |
| void |
- |
- |
- |
Void |
High-precision digital BigInteger and bigdecimal encapsulate int and float operations respectively
An array of 2.2.3 Java
int a[]=new int[3];//like creating an array
2.3 Never destroy objects
Scope: The space in which an object can be used
Life cycle: Save time in memory
Class data: As an entire class exists DEMO.D, only one storage space, change all objects visible
Class method: As an entire class exists DEMO.F (), only one storage space
2.4 Coding Style
Class name first letter, using hump naming