The Java language specification states that the escapes inside strings are the "normal" C ones like
and
, but they also specify octal escapes from
to 377
. Specifically, the JLS states:
OctalEscape:
OctalDigit
OctalDigit OctalDigit
ZeroToThree OctalDigit OctalDigit
OctalDigit: one of
0 1 2 3 4 5 6 7
ZeroToThree: one of
0 1 2 3
meaning that something like 4715
is illegal, despite it being within the range of a Java character (since Java characters are not bytes).
Why does Java have this arbitrary restriction? How are you meant to specify octal codes for characters beyond 255?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…