RandomAccess interface is used by List implementations for the indication that they are supporting fast. For example, consider two lists 1 areaList and 2 secondAreaList. A developer can join them using addall like:. Deque is Java, an interface that extends Queue interface. It gives support for the insertion and deletion of elements at both the end. This Queue is also called a double-ended queue. LinkedHashMap is the implementation of the Map interface. It can also extends the HashMap class. It has a nested interface in Map.
This interface must be qualified by the name of class or interface, which it is a member. Therefore it is qualified as a Map. It represents a key and value pair that can forms element of a Map. This method returns a view of the collection. For example, consider cityMap as a map. The developer can use entrySet to get the set view of map having an element Map. Programmer can also use getKey and getValue of the Map. Entry to get the pair of key and value of the map. Java collection framework method, Collections.
LinkedList class in Java implements Deque and List using a doubly linked list. There is a private class node in a doubly-linked list which provides its structure. It also has an item variable for holding the value and reference to Node class. This can be used for connecting the next and previous nodes. The developer cannot directly iterate map, but, this interface has two methods that gives view set of map. These methods are:. It can also implements the NavigableMap interface and can extends the AbstractMap class.
HashSet in Java internally uses HashMap to store elements. It can also store unique values with no duplicate values. In Java, HashSet developer can have add E e method that takes just the element to add as a parameter. It does not accept the key and value pair. The Big-O notation depicts the performance of an algorithm as the number of elements in ArrayList. A developer can use Big-O notation to choose the collection implementation.
It is based on performance, time, and memory. For example, ArrayList get index i is a method to perform a constant-time operation. It does not depend on the total number of elements available in the list. Therefore, the performance in Big-O notation is O 1. The Iterator is an interface that provides methods to iterate Collection. Iterator can take the place of Enumeration in Java.
It allows the caller to remove elements from the collection. The method provides a generic way for traversal using elements of the collection and implementing iterator design pattern. Java collection Framework programmer can iterate over a list in two ways: 1 Using iterator, and 2 using it for each loop.
Skip to content. The class is based on the basic principle of last-in-first-out. In addition to the basic push and pop operations, the class provides three more functions of empty, search and peek. The class can also be referred to as the subclass of Vector. It is thread-safe which might be overhead in an environment where thread safety is not needed.
An alternate to Stack is to use ArrayDequeue which is not thread-safe and has faster array implementation. This interface is dedicated to storing all the elements where the order of the elements matter. For example, whenever we try to book a ticket, the tickets are sold on a first come first serve basis.
Therefore, the person whose request arrives first into the queue gets the ticket. There are various classes like PriorityQueue , ArrayDeque , etc. Since all these subclasses implement the queue, we can instantiate a queue object with any of these classes. For example,. The most frequently used implementation of the queue interface is the PriorityQueue. Priority Queue: A PriorityQueue is used when the objects are supposed to be processed based on the priority.
It is known that a queue follows the First-In-First-Out algorithm, but sometimes the elements of the queue are needed to be processed according to the priority and this class is used in these cases. The PriorityQueue is based on the priority heap. The elements of the priority queue are ordered according to the natural ordering, or by a Comparator provided at queue construction time, depending on which constructor is used.
Deque Interface : This is a very slight variation of the queue data structure. Deque , also known as a double-ended queue, is a data structure where we can add and remove the elements from both ends of the queue. This interface extends the queue interface. The class which implements this interface is ArrayDeque. Since ArrayDeque class implements the Deque interface, we can instantiate a deque object with this class.
The class which implements the deque interface is ArrayDeque. ArrayDeque: ArrayDeque class which is implemented in the collection framework provides us with a way to apply resizable-array. This is a special kind of array that grows and allows users to add or remove an element from both sides of the queue. Array deques have no capacity restrictions and they grow as necessary to support usage.
Set Interface : A set is an unordered collection of objects in which duplicate values cannot be stored. This collection is used when we wish to avoid the duplication of the objects and wish to store only the unique objects. Since all the subclasses implement the set, we can instantiate a set object with any of these classes. Skip to content. Change Language. Related Articles. Basics of Java.
Operators in Java. Packages in Java. Flow Control in Java. Loops in Java. Jump Statements in Java. Arrays in Java. Strings in Java. OOPS in Java. Constructors in Java. Interfaces in Java. Perimeter Of Rhombus. Volume Of Cone Java Program. Volume Of Prism. Volume Of Cylinder. Volume Of Sphere. Curved Surface Area Of Cube. Total Surface Area Of Cylinder. Factorial Program In Java. Calculate Electricity Bill.
Calculate Average Of N Numbers. Calculate Discount Of Product. Calculate Distance Between Two Points. Calculate Commission Percentage. Power In Java. Deprecation Program. Calculate Batting Average. Compound Interest Java Program. Calculate Average Marks. Addition Of Two Numbers. Sum Of N Numbers. Armstrong Number In Java. Reverse A String In Java.
Matrix Multiplication In Java. Future Investment Value. Java Program Vowel Or Consonant. Perfect Number In Java. Addition Of Two Matrices. Subtract Two Matrices. Transpose Of Matrix. Check Leap Year Or Not. Prime Number Java Program. Reverse An Array Program. Insert An Element in Array. Linear Search In Java. Merge Sort Java. Selection Sort. Implement Bubble Sort. Quick Sort Java. Insertion Sort. Convert Octal To HexaDecimal. Convert Decimal To Hexadecimal.
Convert Decimal To Octal. Convert Decimal To Binary. Print Hollow Mirrored Rhombus. Print Mirrored Rhombus Star Pattern. Invert Pyramid Star Pattern.
Hollow Right Triangle Star Pattern. Hollow Rhombus Star Pattern. X Star Pattern. Square Star Pattern. Right Arrow Star Pattern. Rhombus Star Pattern. Pyramid Star Pattern. Plus Star Pattern. Mirrored Right Triangle. Left Arrow Star Pattern.
Hollow Diamond Star. Half Diamond Star Pattern Program. Inverted Right Triangle Star. Hollow Inverted Pyramid Star Pattern. Hollow Pyramid Star. Hollow Inverted Mirrored Right Triangle. Inverted Mirrored Right Triangle.
Hollow Mirrored Right Triangle. Hollow Rhombus Pattern. Fun 2. Fun Example : 2. Lang program. Class Abc.
0コメント