当前位置:网站首页>2.Collection interface

2.Collection interface

2022-08-09 09:33:00 come here my bear

Java Collection Interface

Collection System Collection

graph TD;Interface.Collection-->Interface.ListInterface.Collection-->Interface.SetInterface.List-->Class.ArrayListInterface.List-->Class.LinkedListInterface.List-->Class.VectorInterface.Set-->Class.HashSetInterface.Set-->Interface.SortedSetInterface.SortedSet-->Class.TreeSet

Interface (interface), Class (implementation class)

The root interface of the architecture, representing a set of objects, called a "collection"(Interface.Collection)

Characteristics of the List interface: ordered, subscripted, and repeatable elements

Characteristics of the Set interface: unordered, no subscripts, and elements cannot be repeated

Collection parent interface

Features: Represents a set of objects of any type, unordered, unsubscripted, and cannot be repeated

Method:

  • boolean add(Object obj) add an object
  • boolean addAll(Collection c) adds all objects in a collection to this collection
  • void clear() clears all objects in this collection
  • boolean contains(Object o) Check if this collection contains o object
  • boolean equals(Object o) Compares this collection for equality with the specified object
  • boolean isEmpty() Check if this collection is empty
  • boolean remove(Object o) removes the o object from this collection
  • int size() returns the number of elements in this collection
  • Object[] toArray() converts this collection to an array
  • iterator() returns an iterator over the elements of this collection
    • hasNext() determines whether there is the next element and returns a boolean value
    • next() gets the next element
    • remove() removes the current element
    • Cannot use the collecton method at the same time ConcurrentModificationException concurrent modification exception
原网站

版权声明
本文为[come here my bear]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208090923103268.html