Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes character unicode values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "character unicode values" Watch "character unicode values" New topic
Author

character unicode values

kathir vel
Ranch Hand

Joined: Jul 03, 2007
Posts: 92
Hi All,
In this pgm they are using unicode values.Should I know all unicodes for all characters for SCJP exam?

01: public static void main(String[] args){
02: char c = '\u0042';
03: switch(c) {
04: default:
05: System.out.println("Default");
06: case 'A':
07: System.out.println("A");
08: case 'B':
09: System.out.println("B");
10: case 'C':
11: System.out.println("C");
12: }
13: }
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by kathir vel:
... Should I know all unicodes for all characters for SCJP exam?...

No. I think this question is just illustrating that a char literal can be expressed as a Unicode value and a char is int convertible (so it can be used in a switch/case). You should know the correct format for a Unicode char literal (for example, '\u0042'), but you do not need to know how the values translate.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I don't think this is actually on the exam, but here's a detail to keep in mind. Unicode carriage returns ('\u000d') and line feeds ('\u000a') are not valid Java literals. The reason is that Unicode values are translated very early by the compiler, so instead of a char literal, it's as if you had an actual carriage return or line feed in your code.

(See 3.10.4 Character Literals and 3.4 Line Terminators.)
 
jQuery in Action, 2nd edition
 
subject: character unicode values