为什么'\117'是Java中的有效字符文字? [英] Why is '\117' a valid character literal in Java?

查看:653
本文介绍了为什么'\117'是Java中的有效字符文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这个 char 定义为
char ch ='\117'



'\117'在什么样的表示

我知道转义顺序'\\\
'
实例或 unicode `\\\�',其中 d 是一个单一的十六进制数字,但我从来没有在我的整个生活中看到'\117'这样的东西!
令人惊讶的是,它编译! (而且输出是 O

解决方案

为ascii。您可以在这里查看更多值: http://donsnotes.com/tech/charsets/ascii.html

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)

解决方案

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

这篇关于为什么'\117'是Java中的有效字符文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆