排序
独梧锁雾
这个作者很懒,什么都没留下…
展开
-
遍历HashMap的三种方式(Iterator,for,entry的迭代器)
遍历HashMap如何遍历HashMap?Key的迭代器Key的for(这里的for是for的另一种用法,普通for无法得出结果,因为set是无序的)对整个entry的迭代器,当然也有for的方法,同理就不列举了import java.util.*;import java.util.Map.Entry;import javax.swing.text.html.parser.Entity;public class TestMap { public static void main(原创 2021-07-04 22:10:42 · 1029 阅读 · 0 评论 -
随机生成一个学生集合并排序(random,Iterable,Collections.sort,Comparator)
随机生成一批学生对象并排序主要知识点:随机生成数据 Random r=new Random(); int score=50+r.nextInt(51);List遍历Iterable it=data.iterable();while(it.hasNext()){System.out.println(it.next().toString);}集合排序Collections.sort(data,new MyComparator)实现comparator接口 class MyCo原创 2021-07-03 22:58:43 · 442 阅读 · 0 评论