【java】如何选用集合

    看需求。

    是否是键值对象形式:

            是:Map

                    键是否需要排序

                            是:TreeMap

                            否:HashMap

                       不知道,就是用HashMap

            否:Collection

                    元素是否唯一:

                            是:Set

                                    元素是否需要排序

                                            是:TreeSet

                                            否:HashSet

                                    不知道,就是用HashSet

                            否:List

                                    要安全吗:

                                            是:Vector

                                            否:ArrayList或则linkedList

                                                       增删多:LinkedList

                                                        查询多:ArrayList

                                            不知道,就使用ArrayList

             不知道,就使用ArrayList

猜你喜欢

转载自blog.csdn.net/rocling/article/details/82814326