What are the Java semantics of an escaped number in a character literal, e.g. '\15' ?

前端 未结 3 1091
长发绾君心
长发绾君心 2020-12-12 20:29

Please explain what, exactly, happens when the following sections of code are executed:

int a=\'\\15\';
System.out.println(a);

this prints

3条回答
  •  伪装坚强ぢ
    2020-12-12 20:49

    The notation \nnn denotes an octal character code in Java. so int a = '\15' assigns the auto-cast'ed value of octal character 15 to a which is decimal 13.

提交回复
热议问题