Differences between Arraylist vs Linkedlist Java Interview Questions | Vector vs Array | Code Decode

preview_player
Показать описание
It covers live demo and in depth explanation of very frequently asked differences like Array VS ArrayList, ArrayList Vs Vector and ArrayList Vs LinkedList.

Udemy Course of Code Decode on Microservice k8s AWS CICD link:

Course Description Video :

Difference between Array and ArrayList.
Array is static in size.
ArrayList is dynamic in size. It can be resized itself when needed.
Array is a fixed length data structure
ArrayList is a variable length Collection class.
An array can store both objects and primitives type.
We cannot store primitive type in ArrayList. It automatically converts primitive type to object.
It performs fast in comparison to ArrayList because of fixed size.
resize() operation : Automatic resize will slow down the performance as it will use temporary array to copy elements from the old array to new array.(by 50%)
add() or get() operation : almost same performance , as for ArrayList object these operations run in constant time.
It is mandatory to provide the size of an array while initializing it directly or indirectly.
We can create an instance of ArrayList without specifying its size. Java creates ArrayList of default size.
We use for loop or for each loop to iterate over an array.
We can use an iterator also to iterate over ArrayList.
Array provides a length variable which denotes the length of an array.
ArrayList provides the size() method to determine the size of ArrayList.
Array can be multi-dimensional.
ArrayList is always single-dimensional.
the elements are contained in adjacent memory locations.
the objects are incapable of being contained in contiguous locations.
The assignment operator is put to use for the storage of elements.
The add() attribute is utilized for the insertion of elements in an ArrayList.
Generics are not compatible with Arrays.
ArrayLists allow the use of Generics.
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Difference between ArrayList and Vector
ArrayList is not synchronized.
Vector is synchronized.
Not Thread Safe
Thread Safe
ArrayList is fast because it is non-synchronized.
.
ArrayList increments 50% of current array size
Vector increments 100% means doubles the array size.
Iterating Values
.
------------------------------------------------------------------------------------------------------------------------------------------------
Difference between ArrayList and LinkedList
ArrayList internally uses a dynamic array to store its elements.
LinkedList uses Doubly Linked List to store its elements.
ArrayList implements only List.
LinkedList implements List as well as Queue. It can acts as a queue as well.
Manipulation with ArrayList is slow because it internally uses an array. If any element is removed from the array, all the other elements are shifted in memory.

LinkedList is slower than ArrayList in storing and accessing data as access requires node by node traversal.
there is no descendingIterator() in ArrayList
LinkedList can be iterated in reverse direction using descendingIterator()
If the constructor is not overloaded , then ArrayList creates an empty list of initial capacity 10
There is no case of default capacity in a LinkedList. Hence an empty list is created when a LinkedList is initialized.
In ArrayList Memory overhead is less as each index only holds the actual object(data).
Memory overhead in LinkedList is more as compared to ArrayList as node in LinkedList needs to maintain the addresses of next and previous node.

Subscriber and Follow Code Decode

#codedecode #javacollectioninterviewquestion #topjavacollectioninterveiwquestion #javainterviewquestion
Рекомендации по теме
Комментарии
Автор

The unique thing about your tutorial is we get to see the actual implementation of framework. Rather than just remembering keywords like synchronised, legacy etc

_bairapraveen
Автор

Thank you for the detailed information. Please share a video on microservices with different databases connection.

muneeswarip
Автор

One of the best explanation as I often thought as of adding element at the end or middle in linked list would be slower but now it’s easier😊

_satveer
Автор

Thanks. Questions like difference between hashmap &hashset, concurrentHashmap and synchronised, hashmap and linkedHashmap, etc.

sourabhjinde
Автор

Great tutorials with demonstration from you.... always.

Gratitude!

mrrishiraj
Автор

i have learnt a lot from your vdos thank you

badakh
Автор

Thanks a lot ... All doughts are cleared about linkedlist and arraylist ..👍👍👌🙂

jainamdesai
Автор

I can trust only two for Java:
Oracle (Sun Microsystems), and
Code Decode
Even when I fail to understand what is explained.

When any of these two says something about a Java concept, it is surely true.

Gratitude for the awesome and very helpful content!

rishiraj
Автор

Thank Mam For this Java Interview Questions and ans Series.
Can You make videos on the Sonar Lint Issues and how can we resolve sonar issues in the code, I know that you definately works on that.

ArjunSingh-isbg
Автор

Great video....can you also explain how lambda expression are handled during compile time please

iloradas
Автор

sorry but i think when the arraylist gets full at that time it uses one formula to resize the list and that is n+(n/2)+1

so suppose we have 10 elements right now the moment we try to add 11th element at that time it will be resized to 16 not to 15. because it uses this formula to resize the list internally

divyeshakabari
Автор

Mam, thank you for this video but plz explain all java 8 coding interview questions like find name who has 2nd highest salary, or salary greater then 2.5k and so on questions plz

islamiyazindagi
Автор

could you please explain internal implementation ArrayList, LinkedList, HashMap, TreeMap

kankipatiashok
Автор

Great tutorials. Learnt alot from your videos. Can you please explain the time complexity for ArrayList and LinkedList ?

shefalibhargava
Автор

please explain differences between abstractlist and abstractsequentiallist

Sharma.Shivam
Автор

very good contents and nice explaination. Please continue to give knowledge. And can we please get these ppt shared with us

jayalaxmirn
Автор

Mam pleased increase frequency of adding content...

ITkedar
Автор

could you please put tutorial of any cloud technology

neelabhrai
Автор

Array list size is increasing by (previous_size*3/2)+1

arvindsingh-brzt
Автор

Hash map and hashset and concurrent map difference with example mam

yatendra__singh