There are various methods in it that are used to insert, delete or access elements. A List is a data structure that is used to store an ordered collection of objects. List: The List interface extends the Collection interface.The syntax of creating objects of all Collection framework classes are the same CollectionClassName objName = new CollectionClassName() Thus, it contains all the declarations of the methods that the Collections will have. The foundation of the Collection framework is built in the Collection interface. It is the root of the Collection hierarchy. Collection: It is the interface that is implemented by all the classes in the collection framework.Therefore all its subclasses also implement the Iterable interface. The Collection interface extends the Iterable interface. Iterable: The iterable interface is the root interface for all collection classes.All the collections are contained in the java.util package and the most basic interfaces are and.Some collections also have some restrictions which we will discuss later in the article. Collections can either be fixed-size or variable-size.Those which are not immutable are known as mutable collections. Like Strings in Java, Collections can also be immutable, i.e., no permanent changes actually take place.And those that support are known as modifiable collections. Collections that do not support modification operations such as add and remove are known as unmodifiable.It can be any of the data types provided by Java. We have to specify the type of object contained in the Collection. This tells us that the Collections are of generic type and when we declare an instance of this interface. For example, the declaration of the Collection interface is public interface Collection. All the core Collection interfaces are generic.A map is not a true Collection since it has a different branch but it is fully integrated with Collections. Set is a special type of Collection and SortedSet is a special type of Set and so on.The core collection interfaces are Collection, List, Queue, Set, SortedSet, Map, and SortedMap.From the above figure, it is clear that the root interfaces are Collection and Map.Here’s an image showing the most important interfaces and classes of the collection framework. It increases the quality of our program and a developer could focus on the application of these collections instead of worrying about their implementation.All the classes that implement these interfaces have some common methods. These contain a basic set of interfaces such as Collection, set, and list. API stands for Application Program Interface. It reduces the effort required to learn, design, and implement APIs.It reduces programming effort since data structures and algorithms are ready to be used and not have to be written again.The framework is highly performance-oriented and efficient and can easily extend and adapt to all collections.It allowed different types of collections to work in a similar manner and with high interoperability. The introduction of Collection Framework in JDK 1.2 unified all the collections and provided a common interface to be used with them. Each of these structures had different syntax and methods for accessing and manipulating data, which caused problems and inefficiency. They did not have any common interface and lacked a unifying theme.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |