Unit-4 Oopj PDF
Unit-4 Oopj PDF
Collections in Java
Java Collections can achieve all the operations that you perform on a
data such as searching, sorting, insertion, manipulation, and deletion.
Iterable Interface
The Iterable interface is the root interface for all the collection classes.
The Collection interface extends the Iterable interface and therefore all
the subclasses of Collection interface also implement the Iterable
interface.
List Interface
ArrayList
LinkedList
Set Interface
LinkedHashSet
SortedSet Interface
Java TreeSet class implements the Set interface that uses a tree for
storage. Like HashSet, TreeSet also contains unique elements. However,
the access and retrieval time of TreeSet is quite fast. The elements in
TreeSet stored in ascending order.
A map contains values on the basis of key, i.e. key and value pair. Each key and
value pair is known as an entry. A Map contains unique keys.
A Map is useful if you have to search, update or delete elements on the basis
of a key.
Java TreeMap class
Using Comparator
The properties object contains key and value pair both as a string. The
java.util.Properties class is the subclass of Hashtable.
It can be used to get property value based on the property key. The
Properties class provides methods to get data from the properties file and
store data into the properties file. Moreover, it can be used to get the
properties of a system.