How to check if a character is an apostrophe?

char, java

Solution

You could simply use `if(c=='\'')` without cast. Or you can use ascii value of apostrophe which is 39. `if (c==39)` will do.

it never actually gets into the 'if ((char) c == '\'') part

The only reason for this could you never pass apostrophe to isWordCharacter(). You can verify it by manually sending `39` or `'\''` to that function.

Problem

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!

Original source