Compare the Difference Between Similar Terms

之间的区别

Home / 技术 / 它 / 数据库 /ArrayList和LinkedList之间的区别

ArrayList和LinkedList之间的区别

February 23, 2018发表Lithmee

关键区别 - arraylist vsLinkedList

Collections are useful for storing data. In a normalarray,数组大小是固定的。有时是需要d to create arrays that can grow as needed. Programming languages such as爪哇has collections. It is a framework with a set ofclasses and interfaces。It serves as a container for a group of elements. Collections allow to store, update , retrieve set of elements. It helps to work with data structures such aslists,,,,sets,树和地图。该列表是集合框架的接口。ArrayList和LinkedList是集合框架中的两个类。他们实现了集合接口并列表接口。本文讨论了ArrayList和LinkedList之间的区别。ArrayList is a class that extends the AbstractList and implements the List interface, which internally uses a dynamic array to store data elements. LinkedList is a class that extends the AbstractSequentialList and implements List, Deque, and Queue interfaces, which internally use a doubly linked list to store data elements.That is the关键区别在ArrayList和LinkedList之间。

CONTENTS

1。概述和关键差异
2。What is ArrayList
3。LinkedList是什么
4。ArrayList和LinkedList之间的相似之处
5。并排比较 - 表格中的arraylist vs linkedlist
6.Summary

What is ArrayList?

ArrayList类用于创建动态数组。与普通数组不同,动态阵列的大小未固定。使用ArrayList类创建的对象可以在列表中存储一组元素。容量会自动增加,因此程序员可以将元素添加到列表中。ArrayList类扩展了实现列表接口的抽象清单类。因此,列表接口的方法可以由ArrayList使用。要访问元素,使用get()方法。add()方法可用于将元素添加到列表中。remove()方法用于将元素从列表中删除。请参阅以下程序。

ArrayList和LinkedList之间的区别

Figure 01: Example of ArrayList

根据上面的程序,创建了一个ArrayList的对象。使用添加方法,可以动态添加元素。使用添加方法添加了元素“ A”,“ B”,“ C”,“ D”和“ E”。删除方法用于从列表中删除元素。将4传递到删除方法时,从列表中删除了第四个索引中的字母。当使用for循环遍历列表时,字母A,B,C和D将打印。

什么是LinkedList?

与ArrayList类似,LinkedList用于动态存储数据元素。使用LinkedList类创建的对象可以在列表中存储一组元素。容量会自动增加,因此程序员可以将元素添加到列表中。它在内部使用双重链接列表来存储数据。在双重链接列表中,数据存储为节点。每个节点包含两个链接。第一个链接指向上一个节点。下一个链接指向序列中的下一个节点。

The LinkedList class extends the AbstractSequentialList class and implements the List interface. Therefore, the methods of List interface can be used by the LinkedList. The get() method can be used to access elements of the list. The add() method can be used to add elements to the list. The remove() method is used to remove an element out of the list. Refer the below program.

ArrayList和LinkedList之间的关键区别

图02:linkedlist的示例

根据上述程序,创建了linkedlist的对象。使用添加方法,可以动态添加元素。使用添加方法添加了元素“ A”,“ B”,“ C”,“ D”和“ E”。删除方法用于从列表中删除元素。将4传递到删除方法时,第四索引中的字母从列表中删除。使用FO循环迭代时,字母A,B,C和D将打印。

What are the Similarities Between ArrayList and LinkedList?

  • Both ArrayList and LinkedList implement List interface.
  • ArrayList和LinkedList都可以包含重复的元素。
  • ArrayList和LinkedList都保持插入顺序。

What is the Difference Between ArrayList and LinkedList?

ArrayList vsLinkedList

ArrayList is a class that extends the AbstractList and implements the List interface which internally uses a dynamic array to store data elements. linkedlist是一个扩展AbstractSequentionList的类,并在内部使用双重链接列表来存储数据元素。
Accessing Elements
Accessing elements of ArrayList is faster than of a LinkedList. Accessing elements of LinkedList is slower than of an ArrayList.
操纵元素
Manipulating elements of ArrayList is slower than of a LinkedList. LinkedList的操纵元素比阵列列表更快。
Behavior
ArrayList performs as a List. LinkedList performs as a List and a Queue.

概括 -ArrayList vsLinkedList

该集合框架允许使用列表,树,地图和集合等数据结构。该列表是集合框架的接口。本文讨论了ArrayList和LinkedList之间的区别。ArrayList是一个扩展抽象列表并实现内部使用动态数组来存储数据元素的列表接口的类。linkedlist是一个扩展AbstractSequentionList的类,并在内部使用双重链接列表来存储数据元素。这就是ArrayList和LinkedList之间的区别。

参考:

1。Introduction to Linked List | Data Structure Tutorial | Studytonight.在这里可用
2.“ Java中的LinkedList - Javatpoint。”,重点,,,,在这里可用
3。“Java ArrayList class – javatpoint.”重点,,,,在这里可用

Related posts:

之间的区别Arrays and Arraylists 之间的区别Arraylist and Vector 显式光标和隐式光标之间的差异 之间的区别PL-SQL and T-SQL 之间的区别Normalization and Denormalization

提交以下:数据库Tagged With:数组列表,,,,arraylist和linkedList差异,,,,ArrayList和LinkedList相似性,,,,阵列列表行为,,,,ArrayList定义,,,,ArrayList Elements,,,,arraylist函数,,,,ArrayList vsLinkedList,,,,比较arraylist和linkedlist,,,,LinkedList,,,,LinkedList行为,,,,LinkedList Definition,,,,LinkedList Elements,,,,linkedlist函数

关于作者:Lithmee

LithmeeMandula is a BEng (Hons) graduate in Computer Systems Engineering. She is currently pursuing a Master’s Degree in Computer Science. Her areas of interests in writing and research include programming, data science, and computer systems.

Comments

  1. Santosh Kumar Sahusays

    2020年5月5日下午4:51

    一篇不错的文章。感谢分享。

    回复
  2. Pankaj Jainsays

    2021年12月23日下午2:35

    The article is well written and informative too.

    But I think could have also added a para saying how can you convert a list to an array under What is ArrayList.

    回复

Leave a ReplyCancel reply

您的电子邮件地址不会被公开。必需的地方已做标记*

Request Article

精选文章

冠状病毒和冷症状之间的差异

冠状病毒和冷症状之间的差异

之间的区别Coronavirus and SARS

之间的区别Coronavirus and SARS

冠状病毒和流感的差异

冠状病毒和流感的差异

之间的区别Coronavirus and Covid 19

之间的区别Coronavirus and Covid 19

You May Like

之间的区别Mule and Hinny

渗透钠和碳酸钠之间的差异

渗透钠和碳酸钠之间的差异

泵和涡轮机之间的差异

光泽和缎子之间的差异

DL蛋氨酸和L蛋氨酸之间的差异

DL蛋氨酸和L蛋氨酸之间的差异

Latest Posts

  • 杀菌剂和农药有什么区别
  • What is the Difference Between Shot Blasting and Grit Blasting
  • What is the Difference Between Epitope and Hapten
  • 消化不良和胃酸反流有什么区别
  • What is the Difference Between Legumes and Cereals
  • What is the Difference Between Serum and Lotion
  • Home
  • 空缺
  • About
  • Request Article
  • Contact Us

版权所有©2010-2018之间的区别。版权所有。使用条款and Privacy Policy:Legal。