美文网首页
[翻译中]JAVA 集合接口介绍

[翻译中]JAVA 集合接口介绍

作者: 翼徳 | 来源:发表于2018-11-12 10:54 被阅读6次

Java 集合接口源于两个最基础的接口 java.util.Collectionjava.util.Map

源于 java.util.Collection 的子接口有:

另一组集合接口基于 java.util.Map ,它并不是真正的集合。然而这些接口包含了集合视图操作,可以使它们像集合一样使用。源于 java.util.Map 的子接口有:

Many of the modification methods in the collection interfaces are labeled optional. Implementations are permitted to not perform one or more of these operations, throwing a runtime exception (UnsupportedOperationException) if they are attempted. The documentation for each implementation must specify which optional operations are supported. Several terms are introduced to aid in this specification:

  • Collections that do not support modification operations (such as add, remove and clear) are referred to as unmodifiable. Collections that are not unmodifiable are modifiable.

  • Collections that additionally guarantee that no change in the Collection
    object will be visible are referred to as immutable. Collections that are not immutable are mutable.

  • Lists that guarantee that their size remains constant even though the elements can change are referred to as fixed-size. Lists that are not fixed-size are referred to as variable-size.

  • Lists that support fast (generally constant time) indexed element access are known as random access lists. Lists that do not support fast indexed element access are known as sequential access lists. The RandomAccess marker interface enables lists to advertise the fact that they support random access. This enables generic algorithms to change their behavior to provide good performance when applied to either random or sequential access lists.

Some implementations restrict what elements (or in the case of Maps, keys and values) can be stored. Possible restrictions include requiring elements to:

  • Be of a particular type.
  • Be not null.
  • Obey some arbitrary predicate.

Attempting to add an element that violates an implementation's restrictions results in a runtime exception, typically a * ClassCastException *, an * IllegalArgumentException * , or a * NullPointerException. Attempting to remove or test for the presence of an element that violates an implementation's restrictions can result in an exception. Some restricted collections permit this usage.

相关文章

  • [翻译中]JAVA 集合接口介绍

    Java 集合接口源于两个最基础的接口 java.util.Collection 和 java.util.Map ...

  • Java中集合类框架及基本接口

    [ ] 介绍Java中的Collection FrameWork。集合类框架的基本接口有哪些 [ ] List, ...

  • [翻译中]JAVA 并发集合介绍

    Concurrent Collections Applications that use collections ...

  • Java集合之ArrayList

    以下翻译自JDK8中的ArrayList源码 Java集合中的动态数组ArrayList是顶层接口List的实现,...

  • java成神之路---集合框架

    标签(空格分隔): java java集合类库的设计思想:“接口与实现分离” java类库中的集合接口和迭代器接口...

  • 集合类-简介

    1.层次关系 2.框架介绍 顶部接口Collection接口是集合类的根接口,Java中没有提供这个接口的直接的实...

  • hashMap理解

    1.环境 jdk:1.8 1.1 介绍 本文介绍将讨论开发中最流行java集合框架中实现map接口HashMap,...

  • Collection接口

    java中的java.util.Collection接口是集合的顶级接口,继承了Iterable接口,jdk中并没...

  • 集合

    集合 Java集合框架 将集合的接口和实现分离 Collection接口 迭代器 泛型使用方法 集合框架中的接口 ...

  • TreeMap理解

    1.环境 jdk:1.8 1.1介绍 本文将介绍java中集合框架中实现Map接口TreeMap ,TreeMap...

网友评论

      本文标题:[翻译中]JAVA 集合接口介绍

      本文链接:https://www.haomeiwen.com/subject/icttvttx.html