Array和List

1. 排序:

Array: Arrays.sort(intervals, (o1,o2)->o1.start-o2.start);  //可以是一个Class
List : intervals.sort((o1,o2)->(o1.start-o2.start)); //intervals 本身是一个Class

2. int[][] = new int[len][] , 只需要指定第一层的维度即可

    List<int[]>  可以把一个int[] 放入List里

3. List 的add 方法  除了直接添加 到List 末尾, 还可以制定index, 这样 后面的自动调整,类似于LinkedList 的插入

      add(int index, E element)

       Inserts the specified element at the specified position in this list (optional operation).

猜你喜欢

转载自www.cnblogs.com/keepAC/p/9821659.html
今日推荐