You can iterate over the characters of the string to build up a set of the unique characters:
String a = "AAABBBAACCBBDD";
Set<Character> charSet = new HashSet<String>();
for (char c : a.toCharArray())
{
charSet.add(c);
}
Then you can convert the set to a list and sort it for display/toString()
purposes:
List<Character> uniqueCharList = new ArrayList<Character>(charSet);
Collections.sort(uniqueCharList);
// Convert List<Character> to char[]
// see http://stackoverflow.com/q/6649100/139010 for a more concise library call
char[] uniqueCharArray = new char[uniqueCharList.size()];
for (int i=0; i<uniqueCharArray.length; i++)
{
uniqueCharArray[i] = uniqueCharList.get(i);
}
String result = new String(uniqueCharArray);