This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: character unicode values
 
Similar Threads
char primitive default value
Unicode characters
switch statement problem
char doubt
q from TestCafe.com