• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can declear char variable to a ''within the number?

 
Hades Pan
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following are valid declarations?
a) char c= ' \' '
b) char c= "cafe"
c) char c= '\ucafe'
d) char c= '\u01001'
e) char c= '0x001'
 
Jennifer Warren
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
compile and u'll know.
Jennifer.
 
Junilu Lacar
Bartender
Posts: 7480
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hades,
Jennifer is quite right. Please take some time to read Valentin's recently posted suggestions about making good use of this forum.
Thanks,
Junilu
 
Rosie Nelson
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(a) and (c) represent valid character literals.
(b) "cafe" is obviously a String Literal
(d) and (e) do not conform to the following:-
UnicodeInputCharacter:
UnicodeEscape
RawInputCharacter
UnicodeEscape:
\ UnicodeMarker HexDigit HexDigit HexDigit HexDigit
UnicodeMarker:
u
UnicodeMarker u
RawInputCharacter:
any Unicode character
HexDigit: one of
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F

Have a look at the JLS for more info.
 
Hades Pan
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think so it is nonsense on forum
Which the correct way to declear char ???
[This message has been edited by Hades Pan (edited December 01, 2001).]
 
Hades Pan
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for Rosie Nelson so detailed explans for me !
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Hades Pan:
Which the correct way to declear char

JLS 3.10.4 tells you that in details
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#100960
HIH

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic