Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

what is the difference ArrayList vs LinkedList

ArrayList is array based, internally uses array
LinkedList consists of nodes/values that are related to each other
ArrayList and LinkedList both keep ordering
ArrayList and LinkedList both allow duplicates
Comment

linked list vs array list vs vector

Compare Types of Lists in Java

ArrayList
(extends AbstractList implements RandomAccess, Cloneable, Serializable)
- is dynamic array
- accepts duplicate elements
- is non-synchronized

LinkedList
(extends AbstractSequentialList implements Deque, Cloneable, Serializable)
- is linked list data scructure
- accepts duplicate elements
- is non-synchronized

Vector
(extends AbstractList implements RandomAccess, Cloneable, Serializable)
- growable or dynamic array of objects
- similar to array, but can grow and shrink
- synchronized


- if getting/setting more, use arrayList
   --dynamic array perofrms better for get/set
- if adding/removing more, use linkedList
   --doubly linked list better for adding removing
- if multi-thread, use Vector over arrayList
   --vector's synchronized nature better for multi-thread
- if not multi-threaded, arraylist better 
   --because it's not synchronized, thus faster
Comment

PREVIOUS NEXT
Code Example
Java :: what are parameters in java 
Java :: how to create a console in java gui 
Java :: spring boot put invalid cors request 
Java :: java code for scientific calculator GUI 
Java :: scanf in java 
Java :: java class in dataweave 
Java :: thread priorities in java 
Java :: generate random number using math.random in java 
Java :: model mapper to list stream 
Java :: thread in java 
Java :: android activity keyboard hide 
Java :: java determine number of cpu cores 
Java :: cannot find symbol iterator in java 
Java :: boolean operators in java 
Java :: maximum number from random number in java 
Java :: android studio clear views of layout 
Java :: java string reduce 
Java :: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 
Java :: android alert change color 
Java :: all possible substrings of a string java of specific length 
Java :: java background color 
Java :: java get number at the end of string 
Java :: what is a package in java 
Java :: java string replace 
Java :: linear serach in java 
Java :: exception class implementation in java 
Java :: remove duplicates from list java 
Java :: capture console output java 
Java :: Adding Entire ArrayList to another ArrayList in Java 
Java :: iterate through arraylist java 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =