Try this piece of code –
public class WhitespaceTest
{
public static void main(String[] args)
{
int x = 0;
char c = (char) x;
System.out.println("c-->"+c+"<---this doesn't print?");
}
}
The output is –
c-->
Why does System.out.println() terminate at ASCII code zero?
I tried this in JCreator LE under Windows 7.
It depends on what your console does (or whatever else is handling
System.out).System.outwill propagate all the information just fine, and if your console attaches no particular meaning to U+0000 then all will be well. However, many UI controls will treat that as a terminating character. This isn’t Java’s “fault” – it’s the UI control itself.(Just for reference, running that code within a Windows command prompt on Windows 7 is fine for me.)