Work with LinkedHashSet и TreeSet in Java

Forums:

LinkedHashSet<Character> chars = 
new LinkedHashSet<Character>(Arrays.asList('B''A''D''C'));
String str = "";
for (char c : chars) {
    str += (str == "" ? "" : "; ") + c;
}
//str is "B; A; D; C"

System.out.printf("%s\n"str);

TreeSet<Character> sortedChars = 
new TreeSet<Character>(Arrays.asList('B''A''D''C'));
str = "";
for (char c : sortedChars) {
    str += (str == "" ? "" : "; ") + c;
}
//str is "A; B; C; D"

char maxValue = sortedChars.last();
//maxValue is 'D'

char minValue = sortedChars.first();
//maxValue is 'A'