Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes character initialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "character initialization" Watch "character initialization" New topic

character initialization

sangeetha balasubramaniam

Joined: May 16, 2005
Posts: 23
I am preparing for SCJP

After executing this program there is no compile time error.My doubt is i thought always char initializtion should be enclosed with single quotes.
Also can someone help me with different forms for caharacter initialization please.

Thanks in Advance,
[ August 31, 2005: Message edited by: Michael Ernest ]
Santana Iyer
Ranch Hand

Joined: Jun 13, 2005
Posts: 335
char stores number, a char store a number
range is from 0 to 65535.

so you can say char c=97; // equvivalent to char c='a'; 'a' ascii is 97

[ August 31, 2005: Message edited by: Santana Iyer ]
[ August 31, 2005: Message edited by: Santana Iyer ]
raghu babu
Ranch Hand

Joined: Jul 05, 2005
Posts: 60

on the other hand following declaration results in a compile time error :

char e = \u0031 ; //observe, no tick marks
I agree. Here's the link:
subject: character initialization
jQuery in Action, 3rd edition