English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Dans ce tutoriel, nous allons étudier l'interface Collection Java et ses sous-interfaces.
L'interface Collection est l'interface racine du cadre de collections Java.
Cette interface n'est pas directement implémentée. Cependant, elle est implémentée par l'intermédiaire de ses sous-interfaces (comme List, Set et Queue).
Par exemple, la classe ArrayList implémente l'interface List, qui est une sous-interface de l'interface Collection.
Comme mentionné précédemment, l'interface Collection inclut des sous-interfaces implémentées par diverses classes dans Java.
L'interface List est une collection ordonnée qui nous permet d'ajouter et de supprimer des éléments comme un tableau. Pour en savoir plus, veuillez consulterJava List interface
The Set interface allows us to store elements in different collections, similar to sets in mathematics. It cannot have duplicate elements. For more information, please visitJava Set interface
When we want toFirst in, first out (FIFO)When storing and accessing elements, you can use the Queue interface. For more information, please visitInterface Queue Java
The Collection interface includes various methods that can be used to perform different operations on objects. These methods are available in all of its subinterfaces.
add() - Insert the specified element into the collection
size() - Return the size of the collection
remove() - Delete the specified element from the collection
iterator() - Return an iterator to access the elements of the collection
addAll() - Add all elements of the specified collection to the collection
removeAll() - Delete all elements of the specified collection from the collection
clear() - Delete all elements from the collection