import java util class List implements Comparable public int value Lis

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.*;
class List implements Comparable{
public int value;
List(int value){
this.value=value;
}
public int compareTo (Object obj){
List tmp =(List)obj;
if (this.value>tmp.value) return 1;
if (this.value<tmp.value) return -1;
return 0;
}
public static void main(String[] args) throws Exception{
List[] objects=new List[10];
for (int i=0;i<10;i++){
System.out.print("Значение "+i+" элемента :");
objects[i]=new List(100 - i);
System.out.println(100-i);
}
System.out.print("Sort:");
Arrays.sort(objects);
for (int i=0;i<10;i++){
System.out.println("Значение "+i+" элемента:"+objects[i].value);
}
}
}