public static String replaceChars(String s,char[] sub,char[] with){
  char[] str=s.toCharArray();
  for (int i=0; i < str.length; i++) {
    char c=str[i];
    for (int j=0; j < sub.length; j++) {
      if (c == sub[j]) {
        str[i]=with[j];
        break;
      }
    }
  }
  return new String(str);
}

public static String replaceChars ( String s , char [ ] sub , char [ ] with ) { char [ ] str = s . toCharArray ( ) ; for ( int i = 0 ; i < str . length ; i ++ ) { char c = str [ i ] ; for ( int j = 0 ; j < sub . length ; j ++ ) { if ( c == sub [ j ] ) { str [ i ] = with [ j ] ; break ; } } } return new String ( str ) ; }
replaces all occurrences of a characters in a string .
