What is the Initial value of unassigned char literal? I thought it to be null & so does the JLS says...JLS Initial Value of Variables
But then why does this runs without null pointer exception?
The output is false false. But when you print ch as System.out.prinln(ch) it prints nothing on screen [ neither null nor 0]. Can someone explian? Source: Enthuware
The "char" data type is a primitive, not a reference type, so you will never get a NullPointerException from one of those.
The initial value of a "char" variable is indeed the null character, as your link to the JLS says. But the null character and the null reference are not the same thing. A null character is (as that link says) simply a character whose Unicode value is zero.
And most output devices are set up to display nothing for a null character. That's why you are seeing nothing when you output it.
I would just add that a char can be widened to type int (or wider). So when an int is expected (for example, as an array index), the null character's numeric value of zero is converted to an int value of zero.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org