So I'm trying to take a string ex. 'Lewd did I live, & evil I did dwel.' and remove all the spaces and special characters so that it just reads 'lewddidiliveevilididdwel' Here's what I have so far...I found this code on a site and it works for removing one character, but how would I edit it so it removes multiple characters? I tried adding more loops and editing it, but haven't been able to make it work. Someone help me out?
public static String removeChar(String hello, char a)
{
String x = "";
for (int i = 0; i < hello.length(); i ++)
{
if (hello.charAt(i) != a)
{
x += hello.charAt(i);
}
}
return x;
}