Solution:
public class RemoveDuplicateInString {
public void removeDuplicate(String s){
System.out.println("Before::"+s);
int len = s.length();
for(int i=0;i<len-1;i++){
char c = s.charAt(i);
String preString = s.substring(0,i+1);
String temp = s.substring(i+1);
temp = temp.replaceAll(""+c, "");
System.out.println("....::"+temp);
s = preString + temp;
len = s.length();
}
System.out.println("After::"+s);
}
public static void main(String args[]){
RemoveDuplicateInString duplicate = new RemoveDuplicateInString();
duplicate.removeDuplicate("adfahagabfgdbah");
}
}