| Author |
char doubt
|
Syed Naimathullah
Greenhorn
Joined: Feb 18, 2007
Posts: 17
|
|
it is giving compile time error at line 1,5 class MCZ11 { public static void main (String[] args) { char a = '\c'; //line 1 char b = '\r'; char c = '\"'; char d = '\b'; char e = '\p'; //line 5 }} please explain me why
|
 |
Akhilesh Trivedi
Ranch Hand
Joined: Jun 22, 2005
Posts: 1493
|
|
Look for escap sequences in java.
|
Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
|
 |
anshi kohli
Ranch Hand
Joined: Jun 30, 2007
Posts: 35
|
|
char range is 0-65535 verified with K&B book but pg 69 of khalid says its 0-65536(which is wrong i believe). please correct if i m wrong?
|
 |
Akhilesh Trivedi
Ranch Hand
Joined: Jun 22, 2005
Posts: 1493
|
|
I would have go home to check pg 69. Still I can vote for 0-65535 range today. Will be back here tomorrow.
|
 |
Hasan Moulana
Greenhorn
Joined: Jul 11, 2007
Posts: 1
|
|
Hi, char a = '\c'; //line 1 char b = '\r'; char c = '\"'; char d = '\b'; char e = '\p'; //line 5 why we use \ inside the quotes is to the characters ', ", ` and for backspace (\b), carriage return (\r) and line feed (\n). I think (\p) does not mean any thing. thtsy it is throwing error. char a = '\r'; //line 1 char b = '\b'; char c = '\"'; char d = 'b'; char e = 'p'; //line 5 if you execute this, it wont show the error.
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
The following are common escape sequences in Java: \b = backspace\f = form feed\n = new line\r = return\t = tab\' = single-quote literal\" = double-quote literal\\ = backslash literalAnd here's a memory device for remembering the first 5: "Big Farms Need Red Tractors." (\b, \f, \n, \r, \t) [ July 12, 2007: Message edited by: marc weber ]
|
"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
|
 |
Priyam Srivastava
Ranch Hand
Joined: Oct 29, 2006
Posts: 169
|
|
|
thanks Marc for that memory device !!!
|
"History would be kind to me, for I intend to write it."
|
 |
Akhilesh Trivedi
Ranch Hand
Joined: Jun 22, 2005
Posts: 1493
|
|
Originally posted by anshi kohli: char range is 0-65535 verified with K&B book but pg 69 of khalid says its 0-65536(which is wrong i believe). please correct if i m wrong?
Hello anshi! me back here. My book titled A programmers guide to java certification by Khalid Mughal and Rolf. W. Rasmussen, second edition with Indian print coyrighted 2004, at page 29 says, second paragraph first line says... "Their values are unsigned integers that denote all the 65536(2^16) characters in the 16-bit unicode character set." So the actual set of characters is 65536, but when you say 'range', it actually starts with 0 and ends up with one minus of the total... cho chimple right. have fun.
|
 |
Jared Folino
Greenhorn
Joined: Apr 27, 2007
Posts: 25
|
|
A good accronym is farms nneed big red tractors
|
 |
 |
|
|
subject: char doubt
|
|
|