If nothing else, you'll be getting a NullPointerException because you keep doing this:str = str.toUpperCase();
str = str.replaceAll("\\W","");The problem is, 'str' is never initialized, so is always...