This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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