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. [EXP]CVE-2019-0604 Microsoft SharePoint RCE Exploit

    研表究明,汉字的序顺并不定一能影阅响读,比如当你看完这句话后,才发这现里的字全是都乱的. 剑桥大学的研究结果,当单词的字母顺序颠倒时,你仍旧可以明白整个单词的意思.其中重要的是:只要单词的第一个字母和 ...

  2. Excel 简单使用

    1.Excel复制上一行 注意鼠标的样子 2.删除多行 删除之后如图所示: 删除多列也是同样的操作 3.日期格式不能按照数据库的形式进行输入 数字的位数太多输入之后改变了数字,可以设置为文本格式,进行 ...

  3. SSL密钥协商过程分析

    一.说明 尽管做过证书生成.双向认证.SSL通信编程等事情,但一直不清楚SSL如何完成密钥交换.看网上的资料则众说纷纭,最近和朋友学习时聊到了这个问题,然后正巧上周处理客户反馈SSL版本过低时领导也想 ...

  4. mySql使用手册-官方文档

    https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format oracle to_ ...

  5. [转帖]/var/log/wtmp文件的作用

    /var/log/wtmp文件的作用 https://blog.51cto.com/oldyunwei/1658778   /var/log/wtmp是一个二进制文件,记录每个用户的登录次数和持续时间 ...

  6. 模拟 --- Crashing Robots

    Crashing Robots Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7394   Accepted: 3242 D ...

  7. QT之类型转换

    Qt在进行数据类型转换时,容易忘记如何使用,或者是早已厌倦了百度QString转QByteArray,QByteArray转char,QString转string....... 现在分享一篇QT数据类 ...

  8. Win10应用商城删除后部分应用出错的解决方案

    出错图示 解决方案 查找完整包名:Get-AppxPackage -allusers | Select Name, PackageFullName Add-appxpackage -register ...

  9. 配置 Log4j 以便查看 MyBatis 操作数据库的过程

    在 src/main/resources中添加 log4j.properties 配置文件 ,输入如下内 容.#全局面已直 log4j .rootLogger=ERROR, stdout #MyBat ...

  10. SQL语句及数据库优化

     1,统一SQL语句的写法 对于以下两句SQL语句,程序员认为是相同的,数据库查询优化器认为是不同的. 所以封装成复用方法,用标准模板来控制. select*from dual  select*Fro ...