Java의 Default Value

Compiler에 의해 초기화 되는 값으로, 아래 표와 같이 초기화 됩니다. 하지만 컴파일러에 의한 초기값으로
의존하는것은 좋은 programming 습관이 아닙니다.

Default Values

It's not always necessary to assign a value when a field is declared. Fields that are declared but not initialized will be set to a reasonable default by the compiler. Generally speaking, this default will be zero or null, depending on the data type. Relying on such default values, however, is generally considered bad programming style.

The following chart summarizes the default values for the above data types.


Data Type

Default Value (for fields)

byte

0

short

0

int

0

long

0L

float

0.0f

double

0.0d

char

'\u0000'

String (or any object)  

null

boolean

false

'프로그래밍 > Java' 카테고리의 다른 글

[Java] 연산자-1  (0) 2016.04.05
[Java] 자료형의 변환  (0) 2016.04.04
[Java] Literals  (0) 2016.04.03
[Java] 자료형  (0) 2016.03.29
[Java] 시작하기  (0) 2016.03.27

+ Recent posts