This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes character literals Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "character literals" Watch "character literals" New topic
Author

character literals

swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 125

A compile-time error is generated at which line?

character literals ..do i need to mug up these .. what is \u followed by no?i saw soo many questions having \u followed by nos.

please suggest any article which will help me to understand this thing .
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
A character literal consists of single-quotes which enclose a single Unicode character or a so-called escape sequence.

For example 'A' is a character literal which represents the uppercase letter A; and '\u0041' is an alternative representation
A for as all sequences of a backslash, followed by an ``u'', and four hex digits (giving 16 bits) are replaced by the corresponding Unicode character. Note that the \u-notation is permitted everywhere in a Java program, not just within character literals. This allows all Unicode characters to be specified within a Java program even if the full Unicode character set is not supported by the current environment.

However, not all Unicode characters can be directly given within a character literal. ''' or '\' are not permitted and likewise neither CR (carriage return) nor LF (line feed) which may be used for line terminators.
Firas Zuriekat
Ranch Hand

Joined: May 09, 2006
Posts: 143
There is no compliler errors and the output is:
abcd'A'A?

I don't think it's on the exam because none of SCJP5 objective mention unicode chars.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Firas Zureikat:
...I don't think it's on the exam because none of SCJP5 objective mention unicode chars.

It's implied through the String and Character classes. You certainly don't need to know Unicode inside out, but you do need to know some basics.


"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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: character literals
 
Similar Threads
Unicode representation of char
Can declear char variable to a ''within the number?
Unicode problem
String
Arithmetic Promotion. What's the deal here?