I have a method that supposed to delete all the dups from string passed inside it. I can print the dups, how can I delete them in the original string ? Say, 'miami' will need to be 'mia' when it will return. Thanks.
public static String removeDups( String str1){
char[] str = str1.toCharArray();
if (str == null) return null;
int len = str.length;
if (len < 2) return new String(str);
char[] newStr = new char[len+1];
int copyLength = 0;
for ( int i = 1 ; i < len; i++){
for( int j=0; j< i; j++){
if ( str[i] == str[j]){
System.out.println(" str[i] == str[j] = "+ str[i] + " , "+str[j]);
break;
}
}
}
return new String(str);
}