• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to listen for char ' and "?  RSS feed

 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code works 100% fine this way...KeyCar1 = char, beck and heck are ints:

if i try:

i get errors..i have tried various way to do this...should i use:

or stick with the char?
Please give examples that directly relate to my code.
Thanks,
cc11rocks
 
Stephan van Hulst
Saloon Keeper
Posts: 7817
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to use the " and ' characters in a Java string or character literal, you will have to escape them. Example:
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much!
It worked,
cc11rocks
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use ' inside Strings and " inside chars without escaping:
' inside chars and " inside Strings need to be escaped as Stephan explained.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!