首页 > 代码库 > JAVA-day07-集合

JAVA-day07-集合

/*
Collection
    List:存储的对象是有序的(取出的顺序和存储的顺序是一致的),对象是可以重复的
	  --ArrayList:底层使用的数据结构是数组,查找速度快,增删速度慢 线程不同步的
	  --LinkedList:底层使用的数据结构是链表,查找速度慢,增删速度快
	  --Vector:底层使用的数据结构是数组,线程同步的

	Set:存储的对象是无序的(取出的顺序和存储的顺序是不一致的),对象不可以重复 
*/
//去掉集合中重复的对象
import java.util.*;
class  Demo1
{
	public static void main(String[] args) 
	{
		ArrayList list = new ArrayList();
		list.add("java01");
		list.add("java02");
		list.add("java03");
		list.add("java02");


		Iterator ite = list.iterator();
		while(ite.hasNext())
		{
			sop(ite.next());
		}

		ArrayList list2 = new ArrayList();
		for(int i=0;i<list.size();i++)
		{
			Object obj = list.get(i);
			if(!list2.contains(obj))//依据什么方式来判断一个对象是否存在这个集合中,依据boolean equals(Object obj)方法来判断是否包含某个对象
			{
				list2.add(obj);
			}
		}
		sop(list2);

		
	}
	//去除重复的功能定义成函数
	public static ArrayList  quChu(ArrayList list)
	{
		ArrayList list2 = new ArrayList();
		for(int i=0;i<list.size();i++)
		{
			Object obj = list.get(i);
			if(!list2.contains(obj))
			{
				list2.add(obj);
			}
		}
		return list2;
	}
	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}




import java.util.*;
class Student
{
	private String name;
	private int  age;

	public Student(){}
	public Student(String name,int age)
	{
		this.name = name;
		this.age = age;
	}

	public boolean equals(Object obj)
	{
		if(!(obj instanceof Student))
			throw new RuntimeException("类型不对");

		Student stu = (Student)obj;
        System.out.println(this.name+"比较"+stu.name);
		//当姓名和年龄相同时返回true
		return this.name.equals(stu.name) && this.age==stu.age;

	}
	public int getAge()
	{
		return this.age;
	}
	public String getName()
	{
		return this.name;
	}
	public String toString()
	{
		return name+","+age;
	}
}
class Demo2 
{
	public static void main(String[] args) 
	{
		ArrayList list = new ArrayList();


		list.add(new Student("lisi",23));
		list.add(new Student("zhangsan",23));
		list.add(new Student("liuneng",22));
		list.add(new Student("zhaosi",21));
		list.add(new Student("zhangsan",23));
        sop(list);
		ArrayList list2 = quChu(list);
		sop(list2);

		//list.remove(new Student("lisi",23));//remove也是依据equals()方法来判断是否存在给对象
		//sop(list);
	}


	public static ArrayList  quChu(ArrayList list)
	{
		ArrayList list2 = new ArrayList();
		for(int i=0;i<list.size();i++)
		{
			Object obj = list.get(i);
			if(!list2.contains(obj))
			{
				list2.add(obj);
			}
		}
		return list2;
	}


	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}

/*
Collection
    List:存储的对象是有序的(取出的顺序和存储的顺序是一致的),对象是可以重复的
	  --ArrayList:底层使用的数据结构是数组,查找速度快,增删速度慢 线程不同步的
	  --LinkedList:底层使用的数据结构是链表,查找速度慢,增删速度快
	  --Vector:底层使用的数据结构是数组,线程同步的

	Set:存储的对象是无序的(取出的顺序和存储的顺序是不一致的),对象不可以重复 
      HashSet:底层使用的数据结构是哈希表,线程不同步的
	  TreeSet:底层使用的数据结构是二叉树,线程不同步的



	  HashSet保证存入集合中的对象唯一的原理:hashCode()和equals()
	                    先判断新加入集合的对象的哈希值是否和集合中所有对象的哈希值相同,如果都不同,则直接加入集合
						如果出现哈希值相同的,再调用boolean equals(Object obj)方法,如果该方法返回true则认为集合中已经存在该对象
						不加入集合

						哈希值相同不一定是同一个对象,但是同一个对象的哈希值肯定相同

*/
import java.util.*;
class Person
{
	public int hashCode()
	{
		return 55;
	}
}
class Demo3 
{
	public static void main(String[] args) 
	{
		HashSet hs = new HashSet();

		hs.add(new Person());
		hs.add(new Person());
		hs.add(new Person());
		/*
		//在使用add方法添加对象时,就保证了加入的对象不重复
		hs.add("java01");
		hs.add("java02");
		hs.add("java01");

		*/		
		Iterator ite = hs.iterator();
		while(ite.hasNext())
		{
			sop(ite.next());
		}
	}


	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}

import java.util.*;
class Student
{
	private String name;
	private int  age;

	public Student(){}
	public Student(String name,int age)
	{
		this.name = name;
		this.age = age;
	}

	public int hashCode()
	{
		return name.hashCode()+age*35;
	}

	public boolean equals(Object obj)
	{
		if(!(obj instanceof Student))
			throw new RuntimeException("类型不对");
		Student stu =(Student)obj;

		return this.name.equals(stu.name) && this.age==stu.age;
	}
	public int getAge()
	{
		return this.age;
	}
	public String getName()
	{
		return this.name;
	}
	public String toString()
	{
		return name+","+age;
	}
}
class  Demo4
{
	public static void main(String[] args) 
	{
		HashSet hs = new HashSet();
		hs.add(new Student("lisi",21));
		hs.add(new Student("zhaosi",22));
		hs.add(new Student("zhangsan",23));
		hs.add(new Student("wangwu",20));
		hs.add(new Student("lisi",21));

		sop(hs);
	}

	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}

/*
Set:存储的对象是无序的(取出的顺序和存储的顺序是不一致的),对象不可以重复 
      HashSet:底层使用的数据结构是哈希表,线程不同步的
	  TreeSet:底层使用的数据结构是二叉树,线程不同步的
	          会对存入集合的对象进行排序
			  该集合保证存入的对象唯一的方式:是compareTo()方法的返回值为0

			  第一种排序方式:让存入集合中的对象具备排序功能,集合按照该对象具备的排序功能进行排序
			                  也就是让对象所属的类实现Comparable接口中的int compareTo()方法

			  第二种排序方式:对象具备的排序功能不是我们所需要的
			                  定义比较器:这个比较器就是让集合知道该怎么排序的,因为在调用add方法之前就需要明确
							  怎么排序
							  把比较器对象作为参数传递给集合的构造方法,集合会调用该比较器对象中的compare() 方法进行排序

			  当集合中的对象具备排序功能,而且存在比较器时,比较器优先

			  当排序的主要条件相同时,要给定次要条件

			  1:Comparable   int compareTo(Object obj)
			  2:Comparator   int compare(Object obj1,Object obj2)			               

*/
import java.util.*;
class  Demo5
{
	public static void main(String[] args) 
	{
		TreeSet ts = new TreeSet();
        //在添加对象的时候就对加入的对象进行了排序
		//因为String实现了Comparable接口中的int compareTo(String str)方法
		ts.add("woeiruowie");
		ts.add("ertrt");
		ts.add("tyutyuityutyutyu");
		ts.add("zxcxzcsd");

		sop(ts);
	}


	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}

import java.util.*;
//让Student具备排序功能 
class Student implements Comparable
{
	private String name;
	private int  age;

	public Student(){}
	public Student(String name,int age)
	{
		this.name = name;
		this.age = age;
	}	
	public int compareTo(Object obj)
	{
	     if(!(obj instanceof Student))
			 throw new RuntimeException("类型错误");
		 Student stu = (Student)obj;
         /*
          if(age>stu.age)
			  return 1;
		  else if(age<stu.age)
			  return -1;
		  else 
			  return 0;*/

         //int num = this.age - stu.age;
		// return num ==0?this.name.compareTo(stu.name):num;
		return -1;
	}

	public int getAge()
	{
		return this.age;
	}
	public String getName()
	{
		return this.name;
	}
	public String toString()
	{
		return name+","+age;
	}
}
// 定义一个比较器,告诉集合该怎么排序的
class CompareByName implements Comparator
{
   public int compare(Object obj1,Object obj2)
	{
          if(!(obj1 instanceof Student))
			 throw new RuntimeException("类型错误");

		  if(!(obj2 instanceof Student))
			 throw new RuntimeException("类型错误");

		   Student stu1 = (Student)obj1;
		   Student stu2 = (Student)obj2;

		   int num = stu1.getName().compareTo(stu2.getName());
		   return num==0?stu1.getAge()-stu2.getAge():num;
    }
}
class Demo6 
{
	public static void main(String[] args) 
	{
		//创建比较器对象
        CompareByName   cbn = new CompareByName();
		// 把比较器对象传给集合
		TreeSet ts = new TreeSet();
		//因为Student对象中没有排序方法,所以集合不知道该怎么排序,所以异常
		//要想可以排序,就要让Student实现Comparable接口

		ts.add(new Student("lisi",21));
		ts.add(new Student("lisi",22));
		ts.add(new Student("zhangsan",23));
		ts.add(new Student("wangwu",20));
		ts.add(new Student("jiangfeng",21));
		sop(ts);
	}

	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}

//按照字符串长度从短到长排序
//字符串本身具备排序功能,但是是按字符串的大小排序的,不符合我们的需求,所以使用比较器
import java.util.*;
//定义一个按按照字符串长短排序的比较器
class CompareByLength implements Comparator
{
	public int compare(Object obj1,Object obj2)
	{
		if(!(obj1 instanceof String))
			 throw new RuntimeException("类型错误");

		  if(!(obj2 instanceof String))
			 throw new RuntimeException("类型错误");

		   String str1 = (String)obj1;
		   String str2 = (String)obj2;

		   return new Integer(str1.length()).compareTo(new Integer(str2.length()));
	}
}
class  Demo7
{
	public static void main(String[] args) 
	{   //定义比较器
        CompareByLength  cbl = new CompareByLength();
		
		TreeSet ts = new TreeSet(cbl);
		ts.add("woeiruowie");
		ts.add("ert");
		ts.add("tyutyuityutyutyu");
		ts.add("zxcxzcsd.x,mv.x,cmv.xcvmx.,cvmx.");

		sop(ts);
	}


	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}

//对"23 45 12 3 67 11"字符串中的数据进行从小到大排序
import java.util.*;
class  Demo8
{
	public static void main(String[] args) 
	{   TreeSet  ts = new TreeSet();
		String str = "23 45 12 03 67 11";
		String[] arr = str.split(" ");

		for(int i=0;i<arr.length;i++)
		{
			ts.add(Integer.parseInt(arr[i]));
		}
		sop(ts);
	}

	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}
/*
泛型:jdk1.5  提高程序的安全
通过<引用数据类型>来接收一种数据类型,作用是在编译时就用该类型来检查集合中添加的对象是否是该类型的
不是则编译不通过,从而把运行时期的问题转移到编译时期,提高了安全性

使用泛型,不用使用强制类型转换了

泛型擦除:泛型只是用于编译时期,编译完之后的class文件是不存在泛型的

*/
import java.util.*;
class  Demo9
{
	public static void main(String[] args) 
	{
		ArrayList<String> list = new ArrayList<String>();

		list.add("wioeuroi");
		list.add("ert");
		list.add("ghjghj");
		//list.add(66);

		Iterator<String> ite = list.iterator();
		while(ite.hasNext())
		{
			//Object obj = ite.next();
			String str = ite.next();
			//String str = (String)obj;
			sop(str.toUpperCase());
		}


	}

	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}


//泛型的定义:
//泛型定义在类上
class Student
{
}
class Worker
{
}
class Tool
{
	private Object obj;
	public void setObject(Object obj)
	{
		this.obj =obj;
	}
	public Object getObject()
	{
		return this.obj;
	}
}
//定义泛型类
class Tools<T>
{
	private T obj;
	public void setObject(T obj)
	{
		this.obj = obj;
	}
	public T getObject()
	{
		return this.obj;
	}
}
class  Demo10
{
	public static void main(String[] args) 
	{
		//不使用泛型,编译通过,但是运行是出问题了
		Tool t = new Tool();
		t.setObject(new Student());
        Object obj = t.getObject();
		Worker worker = (Worker)obj;

		Tools<Student> tt = new Tools<Student>();
		tt.setObject(new Student());
		Worker w = tt.getObject();
	}
}


/*

class Tool
{
	private Student stu;
	public void setStudent(Student stu)
	{
		this.stu =stu;
	}
	public Student getStudent()
	{
		return this.stu;
	}
}
class Tool2
{
	private Worker worker;
	public void setWorker(Worker worker)
	{
		this.worker =worker;
	}
	public Worker getWorker()
	{
		return this.worker;
	}
}

*/


/*
泛型用在方法上
*/

class Test<T>
{
	//当一个方法中的参数的类型只有当类上的泛型确定了才能确定,这个时候就在方法上使用泛型
	public void show(T t)
	{
		System.out.println(t);
	}
	//一个方法的参数可以是任意类型--该方法单独使用泛型
	public <E> void fun(E e)
	{
		System.out.println(e);
	}

	//静态方法---在进内存的时候还没有对象,所以只能自己使用泛型
	public static <T> void  func(T t)
	{
	   System.out.println(t);
	}
}

class  Demo11
{
	public static void main(String[] args) 
	{
		Test<Integer> test = new Test<Integer>();
        //这个方法只能接收Integer类型的实参 
		//test.show(78);

		test.fun(66);
		test.fun("66");
	}
}

//泛型定义在接口上
interface inter<E>
{
	public void show(E e);
}

class Test implements inter<String>
{
	public void show(String e)
	{
	   System.out.println(e);
	}
}

class Test2<E> implements inter<E>
{
	public void show(E e)
	{
	   System.out.println(e);
	}
}
class  Demo12
{
	public static void main(String[] args) 
	{
		Test2<Integer> t = new Test2<Integer>();
	}
}

//通配符: ?
import java.util.*;
class  Demo13
{
	public static void main(String[] args) 
	{
		ArrayList<String> list = new ArrayList<String>();
		list.add("wioeuroi");
		list.add("ert");
		list.add("ghjghj");
        
		dieDai2(list);

		ArrayList<Integer> list2 = new ArrayList<Integer>();
		list2.add(33);
		list2.add(44);
		list2.add(55);

		dieDai2(list2);
	}
	//使用通配符进行迭代
	public static void dieDai2(Collection<?> coll)
	{
	    Iterator<?> ite = coll.iterator();
		while(ite.hasNext())
		{
			sop(ite.next());//不能使用特有方法
		}
	}
    //泛型方法实现迭代 
	public static <Q> void dieDai(ArrayList<Q> list)
	{
		Iterator<Q> ite = list.iterator();
		while(ite.hasNext())
		{
			Q obj =ite.next();
            sop(obj);
		}
	
	}

	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}

//泛型限定:
//  ? extends E  :接收E类型,以及E的子类类型,确定了上限 
//  ? super E  :接收E类型,以及E的父类类型,确定了下限 
import java.util.*;
class Person
{
	private String name;
	private int age;

	public Person(String  name,int age)
	{
		this.name = name;
		this.age = age;
	}
	public String toString()
	{
		return this.name+","+age;
	}
}
class Student extends Person
{
   public Student(String name,int age)
	{
	   super(name,age);
    }
}
class Worker extends Person
{
	public Worker(String name,int age)
	{
		super(name,age);
	}
}
class  Demo14
{
	public static void main(String[] args) 
	{
		ArrayList<Student> list = new ArrayList<Student>();

		list.add(new Student("lisi",21));
		list.add(new Student("zhangsan",22));
		list.add(new Student("wangwu",20));

		dieDai(list);

		ArrayList<Worker> list2 = new ArrayList<Worker>();

		list2.add(new Worker("laoli",41));
		list2.add(new Worker("laozhang",32));
		list2.add(new Worker("xiaowang",20));

		dieDai(list2);

	}

	public static void dieDai(ArrayList<? extends Person> list)
	{
	       Iterator<? extends Person> ite = list.iterator();
		   while(ite.hasNext())
		   {
		       Person person =  ite.next();//多态
			   sop(person);

		   }
	}
	public static void sop(Object obj)
	{
		System.out.println(obj);
	}
}
//泛型上限的应用
import java.util.*;
class  Demo16
{
	public static void main(String[] args) 
	{
		 
		
		TreeSet<Student> list = new TreeSet<Student>();

		list.add(new Student("lisi",21));
		list.add(new Student("zhangsan",22));
		list.add(new Student("wangwu",20));

		

		TreeSet<Worker> list2 = new TreeSet<Worker>();

		list2.add(new Worker("laoli",41));
		list2.add(new Worker("laozhang",32));
		list2.add(new Worker("xiaowang",20));
         //TreeSet<E>
		//TreeSet(Collection<? extends E> c)


		TreeSet<Person> ts = new TreeSet<Person>(list);
		TreeSet<Person> ts = new TreeSet<Person>(list2);


	}
}


//泛型下限的应用
import java.util.*;
class Person
{
	private String name;
	private int age;

	public Person(String  name,int age)
	{
		this.name = name;
		this.age = age;
	}
	public String toString()
	{
		return this.name+","+age;
	}
}
class Student extends Person
{
   public Student(String name,int age)
	{
	   super(name,age);
    }
}
/*
class Compare1 implements Comparator<Student>
{
	public int compare(Student stu1,Student stu2)
	{
	
	}
}
class Compare2 implements Comparator<Worker>
{
	public int compare(Worker stu1,Worker stu2)
	{
	
	}
}
*/
class Compare implements Comparator<Person>
{
	public int compare(Person stu1,Person stu2)
	{
	   
	}
}
class  Demo16
{
	public static void main(String[] args) 
	{      
		   //TreeSet<E>
		   //TreeSet(Comparator< ? super E> comparator) 

	    TreeSet<Student> list = new TreeSet<Student>(new Compare());

		list.add(new Student("lisi",21));
		list.add(new Student("zhangsan",22));
		list.add(new Student("wangwu",20));

		TreeSet<Worker> list2 = new TreeSet<Worker>(new Compare());

		list2.add(new Worker("laoli",41));
		list2.add(new Worker("laozhang",32));
		list2.add(new Worker("xiaowang",20));

	}
}
/*
集合:
Map:接口,存储的是键值对,一对一对的存,键不能重复
    HashMap:数据结构是哈希表,线程不安全的,可以存储null键 null 值
	TreeMap:数据结构是二叉树,线程不安全的

Map
方法:

添加:
 V put(K key, V value) 
 void putAll(Map<? extends K,? extends V> m)
 
删除:
 V remove(Object key) 
 void clear() 
         
获取:
  V get(Object key) 

  Set<K> keySet() 
  Set<Map.Entry<K,V>> entrySet() 
  int size() 
  Collection<V> values() 
判断:
   boolean isEmpty() 
   boolean containsKey(Object key) 
   boolean containsValue(Object value) 


*/
import java.util.*;
class  Demo17
{
	public static void main(String[] args) 
	{
		HashMap<String,String>  hm = new HashMap<String,String>();
        //返回的是上一次添加的值
		sop(hm.put("001","lisi"));
		sop(hm.put("001","liuneng"));

		hm.put("002","zhangsan");
		hm.put("003","wangwu");

		String value = http://www.mamicode.com/hm.remove("001");>

/*
发现map中没有迭代器,那么该如何遍历集合:
1:Set<K> keySet() :  获取所有的键,存到一个set集合中,并返回这个set集合对象,set有迭代器,使用set的迭代器进行迭代
                      每次迭代出来的是一个键,在根据键来获取值



2:Set<Map.Entry<K,V>> entrySet():获取每个键值对儿形成的映射关系,存到一个set集合中,这个set集合中存储的就是多个映射关系了
                                 ,遍历这个set集合时,每次遍历出来的就是一个映射关系,这个关系中既能得到键,也能得到值
								 这个映射关系是 Map.Entry<K,V>
								 Entry是定义在Map接口中的一个静态接口,
								 为什么把Entry定义在Map接口内部?
								 因为有了map集合,有了集合中的键值对,才会存在映射关系,所以这种映射关系是对集合内部事物的
								 描述,所以应该定义在Map接口内部


*/
import java.util.*;
class  Demo18
{
	public static void main(String[] args) 
	{
		HashMap<String,String>  hm = new HashMap<String,String>();
        //返回的是上一次添加的值
		hm.put("001","lisi");
		hm.put("004","liuneng");
		hm.put("002","zhangsan");
		hm.put("003","wangwu");

        //使用entrySet()遍历集合
		Set<Map.Entry<String,String>>  entry = hm.entrySet();
		Iterator<Map.Entry<String,String>> ite = entry.iterator();
		while(ite.hasNext())
		{
			Map.Entry<String,String>  en = ite.next();
			String key = en.getKey();
			String value = http://www.mamicode.com/en.getValue();>


//什么时候使用Map?
/*
当存在映射关系时
每个学员都有家庭住址
*/
import java.util.*;
class Student implements Comparable<Student>
{
	private String name;
	private int  age;

	public Student(){}
	public Student(String name,int age)
	{
		this.name = name;
		this.age = age;
	}
	public int compareTo(Student stu)
	{
		int num = this.age-stu.age;
		return num==0?this.name.compareTo(stu.name):num;
	}
	public int hashCode()
	{
		return name.hashCode()+age*36;
	}
	public boolean equals(Object obj)
	{
		if(!(obj instanceof Student))
			throw new RuntimeException("类型出错");
		Student stu =(Student)obj;
		return this.name.equals(stu.name) && this.age==stu.age;
	}
	public int getAge()
	{
		return this.age;
	}
	public String getName()
	{
		return this.name;
	}
	public String toString()
	{
		return name+","+age;
	}
}

class Demo19 
{
	public static void main(String[] args) 
	{
		HashMap<Student,String> map = new HashMap<Student,String>();
        //保证键唯一的原理和HashSet一样:hashCode()  equals()
		map.put(new Student("zhangsan",22),"beijing");
		map.put(new Student("lisi",23),"hanguo");
		map.put(new Student("wangwu",22),"shanghai");
		map.put(new Student("liuneng",56),"tieling");
		map.put(new Student("liuneng",56),"tieling");



		Set<Map.Entry<Student,String>> entry = map.entrySet();
		Iterator<Map.Entry<Student,String>> ite = entry.iterator();
		while(ite.hasNext())
		{
			Map.Entry<Student,String> en = ite.next();
			Student key = en.getKey();
			String  value = http://www.mamicode.com/en.getValue();>

/*
HashMap:保证键唯一的原理和HashSet相同
TreeMap:保证键唯一的原理和TreeSet相同
*/


import java.util.*;
class Demo20 
{
	public static void main(String[] args) 
	{
		//根据键排序:键所对应的类要实现Comparable接口中的compareTo方法
		//或者使用比较器
		//保证键唯一的原理是:compare或compareTo方法的返回值是否为0
		TreeMap<Student,String> map = new TreeMap<Student,String>();
        
		map.put(new Student("zhangsan",22),"beijing");
		map.put(new Student("lisi",23),"hanguo");
		map.put(new Student("wangwu",22),"shanghai");
		map.put(new Student("liuneng",56),"tieling");
		map.put(new Student("liuneng",56),"tieling");



		Set<Map.Entry<Student,String>> entry = map.entrySet();
		Iterator<Map.Entry<Student,String>> ite = entry.iterator();
		while(ite.hasNext())
		{
			Map.Entry<Student,String> en = ite.next();
			Student key = en.getKey();
			String  value = http://www.mamicode.com/en.getValue();>


/*
Map:
每个班有多个学员

键:String
值:List<Student>
*/

import java.util.*;
class Demo21 
{
	public static void main(String[] args) 
	{
		HashMap<String,List<Student>>  map = new HashMap<String,List<Student>>();

		List<Student> ban1 = new ArrayList<Student>();

		ban1.add(new Student("lisi",20));
		ban1.add(new Student("xiaohei",21));
		ban1.add(new Student("xiaobai",22));
		
		List<Student> ban2 = new ArrayList<Student>();

		ban2.add(new Student("zhangsan",20));
		ban2.add(new Student("lixia",21));
		ban2.add(new Student("wanggang",22));

		map.put("java",ban1);
		map.put("android",ban2);


       Set<Map.Entry<String,List<Student>>> entry = map.entrySet();
	   Iterator<Map.Entry<String,List<Student>>> ite = entry.iterator();
	   while(ite.hasNext())
		{
	       Map.Entry<String,List<Student>>  en = ite.next();
		   String key = en.getKey();
		   sop("班级名称"+key);
		   List<Student> value = http://www.mamicode.com/en.getValue();>


JAVA-day07-集合