user1298336 user1298336 - 4 years ago 186
Java Question

what's the default value of char?

char c = '\u0000';


When I print c, it shows 'a' in the command line window.

So what's the default value of a char type field?

Someone said '\u0000' means null in unicode; is that right?

Answer Source

The default value of a char attribute is indeed '\u0000' (the null character) as stated in the Java Language Specification, section ยง4.12.5 Initial Values of Variables .

In my system, the line System.out.println('\u0000'); prints a little square, meaning that it's not a printable character - as expected.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download