| Author |
Character (primitive type)
|
Varun Goenka
Ranch Hand
Joined: Mar 09, 2009
Posts: 37
|
|
|
Does a char variable have some default value? Like garbage value?
|
From The Demon,
with love.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16815
|
|
Varun Goenka wrote:Does a char variable have some default value? Like garbage value?
The default value for a char is a nul character -- which has an ascii value of zero.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
It's '\0', or simply 0 (as an integer literal).
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
That is the default value for a field; all fields have default values of 0, which is interpreted as the null character for a char, false for a boolean, and null for all reference types.
Local variables and parameters do not have default values at all.
|
 |
 |
|
|
subject: Character (primitive type)
|
|
|