Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Checking for qoutation marks?

  Asked By: Geeske    Date: Nov 27    Category: Java    Views: 837

How can I compare a string to a quotation mark? I using if
(string.equals(""")) will just give me an unclosed string error. Can
I use ASCII in java (one of the few things I actually perefere C++
over Java for)?



2 Answers Found

Answer #1    Answered By: Julio Morgan     Answered On: Nov 27

the quotation mark  is a special character in a string. If you want to
read a special character as a string  literal then you place a control
character in front of it. In this case the \ character

"and bob said \"Hi how are you?\""

You probably could use ucode or ascii, but you don't need to.

Answer #2    Answered By: Opal Alexander     Answered On: Nov 27

You must use the escape character \" if you want the string  to include
a the quotation mark  character.

Didn't find what you were looking for? Find more on Checking for qoutation marks? Or get search suggestion and latest updates.