In this tutorial, we will learn about the Set interface in Java and its methods. The Set interface of the Java Collections framework provides the features of the mathematical set in Java. It extends the Collection interface. Unlike the List interface, sets cannot contain duplicate elements. Classes that implement Set Since Set is an interface, we cannot create objects from it. In order to use… Continue reading Java Set Interface
Month: February 2022
Linked Hash Map
In this tutorial, we will learn about the Java LinkedHashMap class and its operations with the help of examples. The LinkedHashMap class of the Java collections framework provides the hash table and linked list implementation of the Map interface. The LinkedHashMap interface extends the HashMap class to store its entries in a hash table. It internally maintains a doubly-linked list among all… Continue reading Linked Hash Map
Hash Map
In this tutorial, we will learn about the Java HashMap class and its various operations with the help of examples. The HashMap class of the Java collections framework provides the functionality of the hash table data structure. It stores elements in key/value pairs. Here, keys are unique identifiers used to associate each value on a map. The HashMap class implements the Map interface. Create a HashMap In order… Continue reading Hash Map
Map Interface
In this tutorial, we will learn about the Java Map interface and its methods. The Map interface of the Java collections framework provides the functionality of the map data structure. Working of Map In Java, elements of Map are stored in key/value pairs. Keys are unique values associated with individual Values. A map cannot contain duplicate keys. And, each key is associated with a… Continue reading Map Interface
Linked List
Here is how we can create linked lists in Java: Here, Type indicates the type of a linked list. For example, Example: Create LinkedList in Java Output In the above example, we have created a LinkedList named animals. Here, we have used the add() method to add elements to the LinkedList. We will learn more about the add() method later in this tutorial. Working… Continue reading Linked List
Deque Interface
In this tutorial, we will learn about the Deque interface, how to use it, and its methods. The Deque interface of the Java collections framework provides the functionality of a double-ended queue. It extends the Queue interface. Working of Deque In a regular queue, elements are added from the rear and removed from the front. However, in a deque,… Continue reading Deque Interface
Priority Queue
In this tutorial, we will learn about the PriorityQueue class of the Java collections framework with the help of examples. The PriorityQueue class provides the functionality of the heap data structure. It implements the Queue interface. Unlike normal queues, priority queue elements are retrieved in sorted order. Suppose, we want to retrieve elements in the ascending order. In this… Continue reading Priority Queue
Queue Interface
In this tutorial, we will learn about the Java Queue interface and its methods. The Queue interface of the Java collections framework provides the functionality of the queue data structure. It extends the Collection interface. Classes that Implement Queue Since the Queue is an interface, we cannot provide the direct implementation of it. In order to use the functionalities of Queue, we… Continue reading Queue Interface
Stack Class
In this tutorial, we will learn about the Java Stack class and its methods with the help of examples. The Java collections framework has a class named Stack that provides the functionality of the stack data structure. The Stack class extends the Vector class. Stack Implementation In stack, elements are stored and accessed in Last In First Out manner. That is, elements are… Continue reading Stack Class
Java Vector
In this tutorial, we will learn about the Vector class and how to use it. We will also learn how it is different from the ArrayList class, and why we should use array lists instead. The Vector class is an implementation of the List interface that allows us to create resizable-arrays similar to the ArrayList class. Java Vector vs. ArrayList In… Continue reading Java Vector