Different outputs

exercise No. 228

Q:

We consider:

Code Output
char value = 10224;
IO.println(value);

Hint: This is no printing error, the output actually shows up.

int value = 10224;
IO.println(value);
10224

Why do we get two different outputs ⟰ and 10224?

Tip

Start from System.out and examine println(...).

A:

  1. 10224 is the Unicode value representing the ⟰ character.

  2. out is a static member in class System of type PrintStream. Within this class the println(...) method is multiply overloaded. Among these are: