I need to check if a character is an apostrophe. This is my code so far:
public boolean isWordCharacter(int c) {
if ((char) c == '\'')
return true;
else return Character.isLetter(c);
}
However, it never actually gets into the if ((char) c == '\'') part. Is there something wrong with the way I check it? Thanks!
You could simply use
if(c=='\'')without cast. Or you can use ascii value of apostrophe which is 39.if (c==39)will do.The only reason for this could you never pass apostrophe to isWordCharacter(). You can verify it by manually sending
39or'\''to that function.