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

前端 未结 3 1084
长发绾君心
长发绾君心 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:48

    The fact that you put the digits in quotes makes me suspect it is interpreting the number as a character literal. The digits that follow must be in octal.

提交回复
热议问题