Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

character initialization

 
sangeetha balasubramaniam
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sangeetha,

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

char e = \u0031 ; //observe, no tick marks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic