Sorry for really stupid question, I’m learning a new language and taking this code:
public class Exercise01 {
int i;
char c;
public static void main(String[] args) {
Exercise01 E = new Exercise01();
System.out.println("i = " + E.i);
System.out.println("c = [" + E.c + "]");
}
}
/* Output:
i = 0
c = [
*/
Why the output does not produce “]” character? Has it something to do with Unicode?
PostEdited: the variable E.c was not initialized for experimentation purpose.
You are trying to print the null character as your
char chasn’t need initialised. i.e.\0Interestingly you can’t copy and paste this character easily as most C code sees this as an end of string marker.I see the
]when I run the code.Try changing your code with
gives me an output of
One way to reproduce this problem is to run on unix
which outputs