Working with Character Literals in Java: Handling the Apostrophe"

  • Context: Comp Sci 
  • Thread starter Thread starter K29
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
K29
Messages
103
Reaction score
0
If I want to work with a character literal, and it is the apostrophe, how do I do this?

For example:

Code:
if(Word.charAt(0)=='a'){
   \\do something
}else{
if(Word.charAt(0)=='''){
   \\do something else
}

Now, Word.charAt(0)==''' isn't allowed. In fact netbeans won't even let me type it. How do I overcome this?

Thanks in advance
 
Physics news on Phys.org