Java Collections Framework
The Java Collections Framework (JCF) is an important part of Java that provides classes and interfaces to work with objects in a collection. Understanding collections is important for all undergraduate students who want to write code that is both effective (efficient), clean (well organized), and sustainable (easy to maintain). In this blog post, we will introduce you to core elements such as: concepts; collections; its classes and other necessary topics as outputs from which one can start using these invaluable facilities.
The Java Collections Framework is a consistent infrastructure to model and manipulate collections, which enables you to do multiple operations including searching, sorting, insertion, deletion and modification of data smoothly. Main interfaces and classes in JCF are composed of List, Set, Map, Queue and their corresponding implementations.
1. List
One form of collection that can arrange data in some sequence but can duplicate its elements is a List. The mainly utilized ways of implementing List interfaces include ArrayList, LinkedList, Vector.
Example: ArrayList
2. Set
a Set is an accumulation of items, which disallows replication in itself. The basic classes are: HashSet; LinkedHashSet and TreeSet.
Example: HashSet
3. Map
A Map is an object, that maps no duplicate keys to values. It usually includes HashMap, LinkedHashMap, and TreeMap.
Example: HashMap
3.Queue
A Queue is used to hold multiple elements prior to processing. The main implementations are LinkedList and PriorityQueue.
Example: LinkedList as Queue
By understanding and utilizing List, Set, Map, and Queue, you can handle data more effectively in your Java programs.
[Akash De Alwis]
[Java Collection Framework]
Subscribe to my newsletter
Read articles from Akash De Alwis directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Akash De Alwis
Akash De Alwis
Undergraduate student ๐๐ค