jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes about default value of char Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about default value of char" Watch "about default value of char" New topic

about default value of char

Sekhar Chand
Ranch Hand

Joined: Apr 05, 2006
Posts: 73
Hi friends,
i have some small doubt regarding in default value of char primitive type.
Actually the default value of char primitive type is o, but when i am trying to print that value, its giving nothing.
But when i am passing that in array as an index, its giving the value of a[0], if a is an array.
I dont why it is showing like .
can anybody tell me this and and clear this idea.

Thanks and regards
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11924

the default value of a char is not the character 'o' (lower case letter O), but the numeric value of 0 (zero). when you try and print it, java knows it's a char, so prints the ascii character associated with that number. if you look at an ascii table, you will see that the number 0 is a null character. it's a non-printing character.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link: http://aspose.com/file-tools
subject: about default value of char
It's not a secret anymore!