/*
transient Object[] elementData; // non-private to simplify nested class access
ArrayList<>() 底层原理是数组
*/
List<Integer> list=new ArrayList<>();
/*
private static class Node<E> {
E item;
Node<E> next;
Node<E> prev;
Node(Node<E> prev, E element, Node<E> next) {
this.item = element;
this.next = next;
this.prev = prev;
}
底层原理是自定义了内部类,链表结构
}
*/
List<Integer> list2=new LinkedList<>();
/*
HashMap即是采用了链地址法,也就是数组+链表的方式。
*HashMap被改变的次数,由于HashMap非线程安全,在对HashMap进行迭代时,
如果期间其他线程的参与导致HashMap的结构发生变化了(比如put,remove等操作),
需要抛出异常ConcurrentModificationException
transient int modCount;
*/
Map<String,Integer> map=new HashMap();
/*
Hashtable 的函数都是同步的,这意味着它是线程安全的。它的key、value都不可以为null。此外,Hashtable中的映射不是有序的。
public synchronized V get(Object key)
public synchronized V put(K key, V value)
*/
Map<String, String> maptable=new Hashtable<>();
Map<String,Integer> map2=new TreeMap<>();
}
JAVA问题记录:List与Map
最新推荐文章于 2024-06-02 22:24:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)