一..Set集合
特点,无序,唯一,无序
二,遍历
1.迭代器
set.forEach(System.out::println);
//2.遍历方式(2种)
//1)foreach
for(Student student : set) {
System.out.println();
}
2. 常用实现类
Set<Student>set=new HashSet<>();
set.add(new Student(1,"zs",80f));
set.add(new Student(2,"ls",30f));
set.add(new Student(3,"ww",150f));
set.add(new Student(4,"zs",120f));
3.NameComparator类
public class NameComparator implements Comparator<Student> {
@Override
public int compare(Student a, Student b) {
// TODO Auto-generated method stub
return -(a.getSname().hashCode()-b.getSname().hashCode());
}
}
4.集合框架类图
5.集合框架概述