문제

While answering one of the question, I came across this interesting situation.

If I have string like the following, Netbeans does not complain that it's an illegal start of expression.

String temp="\19825655.";

As soon as I remove '1' it complains that it's an illegal start of expression.

String temp="\9825655.";

couldn't figure out the reason for this behavior. Any input would be appreciated.

Observation: It seems \9 and \8 has special meaning. Only for \9 and \8 I am getting illegal start of expression. All other combinations it is not complaining.

도움이 되었습니까?

해결책

\1 is an octal escape code. Check it out in the JLS in Escape Sequences for Character and String Literals.

다른 팁

Right, so what this means is that the combination \1 is an escape sequence. However, to my knowledge it isn't a known escape sequence.

EDIT: OK it's an octal number, interesting - \x Escape in Java?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top