JAVA: ArrayList、LinkedList集合自身的特点

一. ArrayList是List接口的大小可变数组的实现。特点是查找快,增删慢

ArrayList本质就是一个长度可变的数组

ArrayList<String> ar = new ArrayList<String>();

ArrayList<String> ar = new ArrayList<String>(50); //可以指定长度

二. LinkedList是List接口链表的实现,特点是增删快,查找慢。单向链

链表可以单独操作开头和结尾,提供了大量首尾操作的方法

add(E e); 继承父类的方法

1. addFirst(E e);将元素插入到列表的开头

2. addLast(E e);将元素添加到列表的结尾

 

get(int index); 继承父类方法

3. getFirst();返回列表第一个元素

4. getLast();返回列表最后一个元素

 

remove(int index); 继承父类方法

5. removeFirst();移除并返回列表的第一个元素

6.removeLast();移除并返回列表的最后一个元素

 

7.pop();从列表所表示的堆栈处弹出一个元素

8.push(E e); 将元素推入此列表

9.isEmpty(); 判断列表中是否包含有元素。

 

posted on 2018-06-18 10:44  adamal  阅读(1477)  评论(0)    收藏  举报