c、将数组里面的所有元素存入到项目根目录下*/
public static void main(String[] args) throws IOException {
//aaaaaaaaaaa();
//bbbbbbbbbb();
int arr[] = {1,3,6,3,5,4,6};
StringBuilder sb = new StringBuilder();
FileOutputStream fos = new FileOutputStream("xxx.txt");
for (int i = 0; i < arr.length; i++) {
sb.append(arr[i]);
}
fos.write(sb.toString().getBytes());
}
@SuppressWarnings("unused")
private static void bbbbbbbbbb() {
int arr[] = {1,3,6,3,5,4};
TreeSet<Integer> ts = new TreeSet<Integer>(new Comparator<Integer>() {
@Override
public int compare(Integer s1, Integer s2) {
int sum=s2-s1;
return sum==0?-1:sum;
}
});
for (int i = 0; i < arr.length; i++) {
ts.add(arr[i]);
}
System.out.println(ts);
}
@SuppressWarnings("unused")
private static void aaaaaaaaaaa() {
int arr[] = {1,3,6,3,5,4};
ArrayList<Integer> list = new ArrayList<>();
ArrayList<Integer> newList = new ArrayList<>();
for (int i = 0; i < arr.length; i++) {
list.add(arr[i]);
}
for (Integer it : list) {
if (!newList.contains(it)) {
newList.add(it);
}
}
System.out.println(newList);
}