char c = -0; // why no compiler error. System.out.println(c);//it prints nothing
When you assign -0 (an int) to a char variable, the compiler casts it to the char represented by the ASCII value of the int. (Well, the UNICODE value actually, but it's the same in this case.)
Really, all a char is is an unsigned, 16-bit integer anyway. "Behind the scenes", it's just a number being stored. In this case -0 is the same as 0, which is the ASCII value for "NULL". (Not a null reference--that's something different.)
So your println() is printing exactly what you're telling it to. It's just that you're essentially telling it to print nothing.
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
a bit of art, as a gift, the permaculture playing cards