String illegal escape character

Answering one of the questions, I came across this interesting situation.

If I have a line like the following, Netbeans does not complain that it is illegal start of expression .

 String temp="\19825655."; 

As soon as I remove the '1', it complains that it is illegal start of expression .

 String temp="\9825655."; 

I could not find out the reason for this behavior. Any input would be appreciated.

Observation: It seems that \9 and \8 are of particular importance. Only for \9 and \8 I get an illegal start of expression . All other combinations do not complain.

+4
source share
2 answers

\1 is the octal exit code. Check it out in JLS in Escape Sequences for characters and string literals .

+13
source

That's right, so that means that the \1 combination is an escape sequence. However, to my knowledge, this is not a known escape sequence.

EDIT: OK, this is an octal number, interesting - \ x Escape in Java?

+1
source

Source: https://habr.com/ru/post/1435532/


All Articles