It'd probably be a better idea to use a switch statement here. Rather than eliminating the character that you don't want from your array (mutation during iteration is evil unless you're using an Iterator
), why don't you use the StringBuilder class to catch all the characters you do want?