• java集合浅析


    参照互联网 - 博客园 - http://www.blogjava.net/EvanLiu/archive/2007/11/12/159884.html。

    Question:

    1.Q:大致讲解java集合的体系结构
       A:List、Set、Map是这个集合体系中最主要的三个接口。 其中List和Set继承自Collection接口。
          Set不允许元素重复。HashSet和TreeSet是两个主要的实现类。
          List有序且允许元素重复。ArrayList、LinkedList和Vector是三个主要的实现类。
          Map也属于集合系统,但和Collection接口不同。Map是key对value的映射集合,其中key列就是一个集合。key不能重复,但是value可以重复。HashMap、         TreeMap和Hashtable是三个主要的实现类。  SortedSet和SortedMap接口对元素按指定规则排序,SortedMap是对key列进行排序。
    2.Q:ArrayList和Vector有什么区别?HashMap和HashTable有什么区别?
       A:Vector和HashTable是线程同步的(synchronized)。性能上,ArrayList和HashMap分别比Vector和Hashtable要好。

    3. (1)Vector 基于Arrayn,是“sychronized”的.

                ArrayList基于Array,ArrayList是非同步的。所以在性能上要比Vector优越一些.

                LinkedList不基于Array,

                所以:基于Array的List(Vector,ArrayList)适合查询,而LinkedList(链表)适合添加,删除操作

        (2)List基本上都是以Array为基础。但是Set则是在HashMap的基础上来实现的,这个就是Set和List的根本区别

        (3)HashSet的存储方式是把HashMap中的Key作为Set的对应存储项

               LinkedHashSet,TreeSet是通过SortedMap来实现的

               HashMap通过hashcode对其内容进行快速查找,而TreeMap中所有的元素都保持着某种固定的顺序,

                    因此, 如果你需要得到一个有序的结果你就应该使用TreeMap(HashMap中元素的排列顺序是不固定的)

  • 相关阅读:
    remote: You are not allowed to push code to this project
    Ubuntu 查看本机的ip
    git跟踪远程分支,查看本地分支追踪和远程分支的关系
    edgedb 基本试用
    influxdb 全家桶运行
    Introducing Outflux: a smart way out of InfluxDB
    使用outflux 导入influxdb 的数据到timescaledb
    edgedb 强大的对象关系数据库
    Announcing the Operate Preview Release: Monitoring and Managing Cross-Microservice Workflows
    goaccess iis w3c 自定义log 格式参考
  • 原文地址:https://www.cnblogs.com/xiaowei-blog/p/4046746.html
Copyright © 2020-2023  润新知