Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
Author

character initialization

sangeetha balasubramaniam
Greenhorn

Joined: May 16, 2005
Posts: 23
Hi,
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,
Sangeetha
[ 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
sangeetha,

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

char e = \u0031 ; //observe, no tick marks
 
 
subject: character initialization