This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Unicode value of char Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Unicode value of char" Watch "Unicode value of char" New topic

Unicode value of char

Yan Bai
Ranch Hand

Joined: Jul 21, 2002
Posts: 125

Why line 1 and 2 compile well? I only know there're 2 ways to represent a char, one is enclosing a char in single quote, like 'x', the other is to using unicode value specified using four hexadecimal digits, preceded by \u. While '101' doesn't fell in these 2. Are there any other ways to define a char?

SCJP 1.4
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
When specifying the character literal as '\...' the dots must be replaced by an octal number, that is the first digit must be between 0 and 3 and the other two digits between 0 to 7. The legal range is '\000' to '\377' (i.e. decimal 0 to 255)
See JLS sections
JLS 3.10.4 Character Literals
JLS 3.10.6 Escape Sequences for Character and String Literals
[ November 01, 2002: Message edited by: Valentin Crettaz ]

[Blog] [Blogroll] [My Reviews] My Linked In
Don't get me started about those stupid light bulbs.
subject: Unicode value of char