Is there a cleaner way for doing this ?
public void change(char x)
{
if(x == 'a')
{
return 'b';
}
else if(x == 'b')
{
return 'a';
}
else if(x == 't')
{
return 'r';
}
else if(x == 'r')
{
return 't';
}
return 'z';
}
I was wondering if there was anything built into Java so that I can swap pairs of characters like a dictionary in Python or is this the best way to do this?