Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is '\117' a valid character literal in Java? [duplicate]

I've seen this char defined as char ch = '\117'

What kind of representation is '\117' in?

I know escaped-sequence is '\n', for instance, or unicode is `\udddd', where d is a single hex digit, but I've never seen such thing as '\117' in my entire life! Surprisingly, it does compile! (And the output is O)

like image 555
user1508893 Avatar asked Feb 19 '13 05:02

user1508893


2 Answers

This is the octal representation for ascii. You can see lots more values of it here: http://donsnotes.com/tech/charsets/ascii.html

like image 165
Daniel Kaplan Avatar answered Nov 15 '22 00:11

Daniel Kaplan


It's in octal, a holdover from C/C++.

like image 40
ldav1s Avatar answered Nov 15 '22 00:11

ldav1s