Dissecting the Program
  • Line 2-4 imports the collection framework classes and interfaces reside in the java.util package.
  • The class hierarchy of the ArrayList is shown above. We observe that ArrayList implements ListCollection and Iterable interfaces. The Collection and Iterableinterfaces define the common behaviors of all the collection implementations. Interface Collection defines how to add and remove an element into the collection. Interface Iterable defines a mechanism to iterate or transverse through all the elements of a collection. Instead of using the interface Collection directly, it is more common to use one of its sub-interfaces, List (an ordered list supporting indexed access), Set (no duplicate elements) or Queue (FIFO, priority queues).
  • In line 8, we construct an ArrayList instance, and upcast it to the List interface. This is possible as the ArrayList implements List interface. Remember that a good program operates on the interfaces instead of an actual implementation. The Collection Framework provides a set of interfaces so that you can program on these interfaces instead of the actual implementation.

https://www.ntu.edu.sg/home/ehchua/programming/java/J5c_Collection.html

java 集合类 列表的更多相关文章

  1. Java集合类--温习笔记

    最近面试发现自己的知识框架有好多问题.明明脑子里知道这个知识点,流程原理也都明白,可就是说不好,不知道是自己表达技能没点,还是确实是自己基础有问题.不管了,再巩固下基础知识总是没错的,反正最近空闲时间 ...

  2. 摘抄转载前辈们的Java集合类总结

    本文摘自 Blue Sky:http://www.cnblogs.com/hubcarl JAVA 集合类介绍和使用 类关系示意图Iterable(接口) │ └--Collection (接口) ├ ...

  3. Java集合类中的哈希总结

    JAVA集合类中的哈希总结 目 录 1.哈希表 2.Hashtable.HashMap.ConcurrentHashMap.LinkedHashMap.TreeMap区别 3.Hashtable.Ha ...

  4. java集合类(五)About Map

    接上篇“java集合类(四)About Set” 这次学完Map之后,就剩队列的知识,之后有关java集合类的学习就将告一段落,之后可能会有java连接数据库,I/O,多线程,网络编程或Android ...

  5. java集合类(三)About Iterator & Vector(Stack)

    接上篇:java集合类学习(二) Talk about “Iterator”: 任何容器类,在插入元素后,还需要取回元素,因为这是容器的最基本工作.对于一般的容器,插入有add()相关方法(List, ...

  6. java 集合类基础问题汇总

     1.Java集合类框架的基本接口有哪些? 参考答案 集合类接口指定了一组叫做元素的对象.集合类接口的每一种具体的实现类都可以选择以它自己的方式对元素进行保存和排序.有的集合类允许重复的键,有些不允许 ...

  7. java 集合类Array、List、Map区别和优缺点

    Java集合类主要分为以下三类: 第一类:Array.Arrays 第二类:Collection :List.Set第三类:Map :HashMap.HashTable 一.Array , Array ...

  8. Java集合详解8:Java集合类细节精讲

    今天我们来探索一下Java集合类中的一些技术细节.主要是对一些比较容易被遗漏和误解的知识点做一些讲解和补充.可能不全面,还请谅解. 本文参考:http://cmsblogs.com/?cat=5 具体 ...

  9. Java集合类常见的问题

    本篇文章将尝试回答一些Java集合类常见的问题,以作知识梳理之用. ArrayList和LinkList以及Vector的区别 就实现方式而言: ArrayList是以数组的方式实现的列表. Link ...

随机推荐

  1. linux 判断一个用户是否存在

    #!/bin/bash read -p "please input a username:" username >&; then echo "user ex ...

  2. Java学习:数据类型转换注意事项

    数据类型的转换 当数据类型不一样时,将会发生数据类型转换. 自动类型转换(隐式) 1.特点 :代码不需要进行特殊处理,自动完成. 2.规则 :数据范围从小到大. //左边是long类型,右边是默认的i ...

  3. DRF的APIView、GenericAPIView、GenericViewSet的原理分析

    一.层次结构 GenericViewSet(ViewSetMixin, generics.GenericAPIView) ---DRF GenericAPIView(views.APIView) -- ...

  4. 剑指offer之面试题2:实现Singleton模式

    来源:剑指offer 这篇主要记录<剑指offer>书籍中的面试题2:实现Singleton模式 使用语言:C# 代码环境:VS2017 总共有5中解法,从前往后依次优化. 结构如下: 前 ...

  5. Java判断两个时间相差的天数

    1.实现目标 输入:两个日期 输出:两个日期相差的天数 2.代码实现 方法1: 通过Calendar类的日期比较.注意:这里需要考虑一下: 日期是跨年份的,如一个是2012年,一个是2015年的   ...

  6. Spring Boot 的自动配置探究、自制一个starter pom

    //TODO @Conditional @Condition

  7. Apache Tomcat 9.0 Tomcat9 服务无法启动。发生服务特定错误: 4.

    在Tomcat的安装目录下,bin文件夹里面 找到tomcat9w.exe 双击进去,将第四页java里面第一个复选框Use default 选中 保存即可启动tomcat9服务

  8. React生命周期中应该做什么事

    React生命周期函数 装载组件触发 0.construct(props) 用来 props--->state 初始化state,并且把props转化为state 1.componentWill ...

  9. Beego 学习笔记二:第一个项目

    第一个MVC项目 1>     使用beego命令,创建一个项目 首先切换到创建项目的位置,输入bee new firstweb命令,创建成功之后会出现一个名为firstweb的文件夹 2> ...

  10. 33、vue中的事件修饰符.stop、.prevent、.self、.capture、.once

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...