Is there a native method in Java to do character swapping inside Strings. I mean, I need to write a function like this everytime and its pretty boring:
public static String modifyString(String str,int x,int y){
char arr[]=str.toCharArray();
char t= arr[x];
arr[x]=arr[y];
arr[y]=t;
String s= new String(arr);
return s;
}
arr[x]^=arr[y]; arr[y]^=arr[x]; arr[x]^=arr[y];