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. angular数据请求 token验证

    angualr的token 验证会经常用在登录,注册等地方 对于token的使用方法按照以下步骤进行使用即可 1.新建一个服务 ng g service services /+服务名  eg:ng g ...

  2. OpenMark

    what's open mark??? http://www.open.ac.uk/openmarkexamples/

  3. jboss/wildfly安全域的密码加密和解密

    加密: java_path=$(source /opt/wildfly/bin/.Beta1.jar:/opt/wildfly/modules/system/layers/base/org/jboss ...

  4. 红黑树和AVL树的区别(转)

    add by zhj: AVL树和红黑树都是平衡二叉树,虽然AVL树是最早发明的平衡二叉树,但直接把平衡二叉树等价于AVL树,我认为非常不合适. 但很多地方都在这么用.两者的比较如下 平衡二叉树类型 ...

  5. redis字符串类型键的二进制操作

    命令名称:setbit 语法:setbit key offset value 功能: 1)对key所存储的字符串值,设置或清除指定偏移量上的位(bit),位的设置或清除取决于value参数,可以是0也 ...

  6. webbrowser实现一个进程一个代理的办法

    public static void RefreshIESettings(string strProxy) { const int INTERNET_OPTION_PROXY = 38; const ...

  7. VS 发布MVC网站缺少视图

    mvc项目发布之后会有一些视图文件缺少,不包含在发布文件中,虽然可以直接从项目文件中直接拷贝过来,但还是想知道是什么原因,发布文件好像没有找到哪里有设置这个的地方 把生成操作:无-改成内容即可 原文

  8. 关于BASE 24 ,BASE 64原理以及实现程序

    关于BASE 24 ,BASE 64原理以及实现程序 来源 https://wangye.org/blog/archives/5/ 可能很多人听说过Base64编码,很少有人听说过Base24编码,B ...

  9. prometheus重启hang住问题记录

    官方issue并不承认这是一个问题,参考: https://github.com/prometheus/prometheus/issues/5727 https://github.com/promet ...

  10. 使用JDBC,完成数据库批量添加数据操作:

    第一步:定义一个key String key = "into 表名(字段1,字段2,字段3)"; 第二步:定义一个可以增长的变量 StringBuffer values = new ...