About
Class (Initialization|Instantiation) in java.
Articles Related
Class Initialization
During an class initialization:
- Java's class loader loads the main method
- Java's byte code verifier verifies the class.
The first initialization is to give to class fields their default values.
| Field Datatype | Default Initialization |
|---|---|
| boolean | false |
| byte | 0 |
| char | |
| double | 0.0 |
| float | 0.0 |
| integer | 0 |
| long | 0 |
| short | 0 |
| string | null |
They can be then initialize with more logics through an static initialization block.
Methods
- directly for primitive type
- directly for primitive wrapper class thanks to autoboxing
- the new operator for all other type
