int hex = 0xA; System.out.println( (char)hex );
The hexadecimal value 0xA (or decimal 10) is equal to "\ n" (new char string) in ASCII.
Hence the way out.
EDIT (thanks halex for correcting the comments:
int hex = (char) 0xA; System.out.println(hex); //here value of hex is '10', type of hex is 'int', the overloaded println(int x) is invoked. int hex = 0xA; System.out.println((char) hex); //this is equivalent to System.out.println( '\n' ); since the int is cast to a char, which produces '\n', the overloaded println(char x) is invoked.
source share