课程: Learning Java Collections

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

The Collection interface

The Collection interface

- [Instructor] Let's explore the design of the collection interface and take a glance at its methods. Since the collection interface is at the root of the interface hierarchy, that means the methods on it appear on every type that extends from it. So interfaces and concrete implementations of a list, set, and queue will inherit these common methods from the collection interface. Some collection methods are denoted as being optional, so they might appear on an implementation, but it's possible that a call to one of these methods will throw an unsupported operation exception. The interfaces in the collections framework and the collection interface itself are generic. So when we create a collection, we use a generic type argument to indicate the type of elements that it holds. The argument is declared by placing the type in angle brackets. Since the collection implementations are based on these interfaces, they use a…

内容