Author | Topic: representation |
Mahen greenhorn |
posted March 07, 2000 09:41 AM
what does this ('\141' )representation mean aval = '\141'; System.out.println(" val of a : " + aval); we get " val of a : " a
|
Saritha Pilla greenhorn |
posted March 07, 2000 09:58 AM
This is the octal representation of a character. For a hexadecimal representation use '\u0141' The output will be different in each case [This message has been edited by Saritha Pilla (edited March 07, 2000).] [This message has been edited by Saritha Pilla (edited March 07, 2000).]
|
maha anna bartender |
posted March 07, 2000 10:17 AM
And one more point regarding this. The octal escape representaton of a char has the foll. format '\digit1 digit2 digit3' //here digit1 can be '\[0-3]', digit2 and digit3 can be '\[0-7]' '\digit1 digit2' //here digit1 and digit2 BOTH can be '\[0-7]' '\digit1' //here digit1 can be '\[0-7]' Eg. char c1 = '\377'; //ok char c2 = '\477'; // NOT ok char c3 = '\77'; //ok char c1 = '\7'; //ok regds maha anna [This message has been edited by maha anna (edited March 07, 2000).]
|
PGautam greenhorn |
posted March 07, 2000 10:20 AM
Hi Saritha, octal representation starts with 0 right?, how come '141' is octal.?, can you please share your thought. Related question, if there is int like 6, how do you write in hexadecimal form, my answer is 0x0006. Is it correct. Thanks
|
Jane Rozen ranch hand |
posted March 07, 2000 10:25 AM
> aval = '\141'; just think of it this way: octal 141 -> decimal 97 -> ascii code for 'a'
|
maha anna bartender |
posted March 07, 2000 10:33 AM
The difference is 0141 is an octal representation of a number. But '\141' is the octal escape sequence representation. char c1 = 0141; char c2= '\141'; BOTH staments represent the SAME char of decimal value 97 I hope this helps. regds maha anna.
|
Jim Yingst sheriff |
posted March 07, 2000 10:40 AM
[ ignore this post, it's incorrect - I'd delete it, but then maha anna's post wouldn't make sense. - Jim ] The octal and hex escape sequences are for use inside single or double quotes, to represent an individual character. Outside of quotes, they don't work. [This message has been edited by Jim Yingst (edited March 07, 2000).]
|
maha anna bartender |
posted March 07, 2000 12:12 PM
Jim, This code seems to work and creates a dir structure ./ABC/DEF when you compile with these options "javac -d . test.java". If I understand you correctly, do you mean to say the foll. code is not a valid code ? regds maha anna code:
|
Jim Yingst sheriff |
posted March 07, 2000 12:21 PM
Ummm... Yes, that is what I meant. Evidently I was wrong. Oops - thanks m.a.!
|
| | |