Java for beginners - Chapter 27 : Collections in Java Part 1 - ArrayList (add(), addAll(), clear())

preview_player
Показать описание
Collections in java.
Collections in java is a framework that provides an design and pattern to store the group of objects.
Operations performed by Java Collections :
Searching
Sorting
Insertion
Manipulation
Deletion etc..

List of collection classes.
Java collection framework has two major components :
Interfaces
Example : Set, List, Deque, Queue etc..
Classes
Example : ArrayList, LinkedList, Hashset, Stack, Queue.

ArrayList Class :
It uses a dynamic array for storing the elements.
It inherits AbstractList class and implements List interface.
Key points about ArrayList class :
It can contain duplicate elements.
It maintains insertion order.
It is non-synchronized.
It allows random access of elements because array works at the index basis.

Important methods of ArrayList Collection :
add(): It is used to insert the specified element at the specified position index in a list.
addAll() : It is used to append all of the elements in the specified collection to the end of the list.
clear() : Clears all the elements in the collection.
trimToSize() : Trims the capacity of this ArrayList instance to be the list's current size.

ankpro
ankpro training
C#
C sharp
Bangalore
Rajajinagar
Selenium
Coded UI
Mobile automation testing
Mobile testing
JQuery
JavaScript
.Net
C
C++
Components of the .Net framework
Hello World
Literal
Keywords
Variable
Data types
Operators
Branching
Loops
Arrays
Strings
Structures
Enums
Functions
Рекомендации по теме