import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
class Person implements Comparable<Person>{
int age;
String fristname,lastname;
public Person(String frist,String last,int ag){
fristname=frist;
lastname=last;
age=ag;
}
public String toString(){
return fristname+" "+" "+lastname;
}
public int compareTo( Person o) {
if(this.age>o.age)
return 0;
else if(this.age<o.age)
return -1;
else
return 0;
}
}
public class Testcontain {
public static void main(String[] args) {
// TODO Auto-generated method stub
List<Person> con=new ArrayList<Person>();
con.add(new Person("f2","l2",25));
con.add(new Person("f1","l1",16));
con.add(new Person("f3","l3",19));
con.add(new Person("f4","l4",16));
System.out.println(con.size());
Object[] person=con.toArray();
Arrays.sort(person);//这个没实现按年龄排序
for(int i=0;i<person.length;i++)
System.out.println(person[i]);
Collections.sort(con);//这个也没实现 为什么呀 怎么回事
System.out.println(Arrays.binarySearch(person,new Person("f2","l2",25) ));
System.out.println(con);
}
}