English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Tutoriel de base Java

Contrôle de flux Java

Java tableau

Java orienté objet (I)

Java orienté objet (II)

Java orienté objet (III)

Gestion des exceptions Java

Java Liste (List)

Java Queue (file d'attente)

Java Map collection

Java Set collection

Java entrée/sortie (I/O)

Java Reader/Writer

Autres sujets Java

Interface de collection (Collection) Java

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.

Les sous-interfaces de Collection

Comme mentionné précédemment, l'interface Collection inclut des sous-interfaces implémentées par diverses classes dans Java.

1.L'interface List

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

2.Set 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

3.Queue 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

Collection methods

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