List集合
WHYWAN123456
这个作者很懒,什么都没留下…
展开
-
ArrayList源码分析
(1) JDK1.8底层是Object类型数组transient Object[] elementData; // non-private to simplify nested class access /** * The size of the ArrayList (the number of elements it contains). * * @serial */private int size;(2)ArrayList list=..原创 2021-11-02 15:38:58 · 74 阅读 · 0 评论 -
LinkedList源码
public class LinkedList<E>{//E是一个泛型,具体的类型要在实例化的时候才会最终确定 transient int size = 0;//集合中元素的数量 //Node的内部类 private static class Node<E> { E item;//当前元素 Node<E> next;//指向下一个元素地址 Node<E> prev.原创 2021-10-20 14:06:30 · 72 阅读 · 0 评论 -
LinkedList 模拟源码
Nodepackage com.why.LinkedList;/** * @Author WangHuaiyu * Created by 5290440298@qq.com * Date on 2021/10/20 13:41 * @Version 1.0 * @Param $ * @return $ */public class Node { private Node pre; private Object obj; private Node next;原创 2021-10-20 13:58:33 · 97 阅读 · 0 评论 -
List集合
import java.util.ArrayList;import java.util.Arrays;import java.util.Collection;import java.util.List;public class Test01 { //这是main方法,程序的入口 public static void main(String[] args) { /* Collection接口的常用方法: 增加:add(E e) addAl...原创 2021-10-19 21:31:16 · 65 阅读 · 0 评论 -
List (ArrayList)遍历方式
public class Test03 { //这是main方法,程序的入口 public static void main(String[] args) { /* List接口中常用方法: 增加:add(int index, E element) 删除:remove(int index) remove(Object o) 修改:set(int index, E element) 查看:get(...原创 2021-10-19 21:40:10 · 142 阅读 · 0 评论