package com.heima.bin;
import java.util.Comparator;
import java.util.TreeSet;
public abstract class sdf {
public static void main(String[] args) {
String line="abccbaeaee";
char[] arr = line.toCharArray();
TreeSet<Character> ts = new TreeSet<>(new Comparator<Character>() {
@Override
public int compare(Character c1, Character c2) {
int num = c1 - c2;
// 补全此处代码
return num == 0 ? -1 : num;
}
});
for(char c : arr) {
ts.add(c);
}
for(Character ch : ts) {
System.out.print(ch);
}
}
}
此处补全代码 num == 0 ? 1 : num 和 num == 0 ? -1 : num 有区别吗 |
|