Java Util Package Tutorial

java.util package contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array). In this tutorial, we will learn important java.util package classes/interfaces and its methods with lots of examples.

Audience

This tutorial has been prepared for the beginners to help them understand the basic functionality related to all the classes and it's methods available in java.util package.

Following are a list of classes under java.util package. I explained all the methods with lots of examples from each class. Our suggestion is to do lots of hands experience using this tutorial.

Click on each class will navigate to their respective page.

java.util Package Classes

>> java.util ArrayList Class

In this article, we will learn all the ArrayList class methods with examples. Java ArrayList class uses a dynamic array for storing the elements. It inherits AbstractList class and implements List interface.

>> java.util.Arrays Class

In this article, we will learn important utility methods of Arrays class with examples. The java.util.Arrays class contains a static factory that allows arrays to be viewed as lists and for manipulating arrays (such as sorting and searching).

>> java.util.Collections Class

java.util.Collections class consists exclusively of static methods that operate on or return collections.
It contains polymorphic algorithms that operate on collections, "wrappers", which return a new collection backed by a specified collection, and a few other odds and ends.

>> java.util EnumMap Class

In this article, we will learn all about EnumMap in Java. What is EnumMap and how to use it with examples?

>> java.util EnumSet Class

In this article, we’ll discuss EnumSet class from the java.util package.EnumSet is a specialized Set implementation for use with enum types. All of the elements in an enum set must come from a single enum type that is specified, explicitly or implicitly, when the set is created. Enum sets are represented internally as bit vectors. This representation is extremely compact and efficient.

>> java.util HashMap Class

In this article, we will learn the HashMap implementation of Map Interface from Java Collections Framework. This article covers all the important HashMap class APIs with examples.

>> java.util HashSet Class

In this article, we’re going to take a look at HashSet class from Java Collections Framework.
We will learn all the APIs that HashSet implementation offers. HashSet class implements the Set interface, backed by a hash table (actually a HashMap instance).

>> java.util IdentityHashMap Class

In this article, we will learn about IdentityHashMap class methods with examples.
The IdentityHashMap is a HashTable based implementation of Map Interface. Normal HashMap compares keys using '.equals' method. But Identity HashMap compares its keys using '==' operator.

>> java.util LinkedHashMap Class

In this article, we will learn LinkedHashMap class implementation of Map interface using examples.
If you want a predictable iteration order of the elements in a Map, then you can use a LinkedHashMap. This article covers all the important APIs that LinkedHashMap Class offers.

>> java.util LinkedHashSet Class

In this article, we will learn the LinkedHashSet class implementation of the Set interface with examples.

>> java.util LinkedList Class

In this article, we will see the Implementation of LinkedList class with examples.
Java LinkedList class uses a doubly linked list to store the elements. It provides a linked-list data structure. It inherits the AbstractList class and implements List and Deque interfaces.

>> java.util TreeMap Class

In this guide, we see the Implementation of TreeMap class using examples.TreeMap is A Red-Black tree based NavigableMap implementation.

>> java.util TreeSet Class

In this article, we will learn TreeSet class methods with examples.

>> java.util WeakHashMap Class

In this article, we will learn WeakHashMap class from java.util package with examples.
WeakHashMap is a Hash table based implementation of the Map interface, with weak keys. An entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use.

java.util Package Interfaces

>> java.util Collection Interface

Collection Interface is the root interface in the collection hierarchy. A Collection represents a group of objects known as its elements. A list, Queue, and Set are all subinterfaces of Collection interface.

>> java.util Comparator Interface

The Comparable interface that we learned in the previous guide defines a default ordering for the objects of a class. This default ordering is also called the natural ordering of the objects.

>> java.util List Interface

In this article, we will learn what is List interface and it's implementations - ArrayList and LinkedList.

>> java util Map Interface

In this article, we will learn what is Map interface and it's three general-purpose implementations: HashMap, TreeMap, and LinkedHashMap.

>> java.util Set Interface

In this article, we will learn what is Set interface and it's three general-purpose Set implementations: HashSet, TreeSet, and LinkedHashSet.

>> java.util SortedMap Interface

A SortedMap is a Map that maintains its entries in ascending order, sorted according to the keys natural ordering, or according to a Comparator provided at the time of the SortedMap creation.

>> java.util SortedSet Interface

A SortedSet is a Set that maintains its elements in ascending order, sorted according to the natural ordering or according to a Comparator provided at SortedSet creation time.


Comments