public class MyClass {
public static String removeRepeatedCharactersFromString(String str) {
StringBuilder sb = new StringBuilder();
int index;
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
index = str.indexOf(ch, i + 1);
if (index == -1) {
sb.append(ch);
}
}
return sb.toString();
}
public static void main(String args[]) {
String str = "The quick brown fox jumps over the lazy dog";
str = removeRepeatedCharactersFromString(str);
str = removeRepeatedCharactersFromString(str);
System.out.println(str);
}
}
/*
run:
Tqickbwnfxjumpsvrthelazy dog
*/