CollecitonFramework(JSDK )一般用途Class作方式
Collection Framework(JSDK )一般用途Class特色与食用范围比较
Collections => Collection是所有List跟Set的始祖List必须以特定次序来持有对象Set无法拥有重复元素
ArrayList => 用Array实做的List允许快速随机存取相较于LinkedList 不适合拿来进行元素安插和移除动作
LinkedList => 提供最佳循序存取适合安插和移除元素随机存取动作比起ArrayList缓慢
HashSet => 是一种collection但是只存放唯一值是把搜寻时间看的很重要的set用hash方式实作的set故access time complexity = O()
TreeSet => 同上但是存入的元素都会经过排列所以速度比HashSet 慢一点
LinkedHashSet =>
Performance is likely to be just slightly below that of HashSet due to the added expense of maintaining the linked list with one exception: Iteration over a LinkedHashSet requires time proportional to the size of the set regardless of its capacity Iteration over a HashSet is likely to be more expensive requiring time proportional to its capacity
BitSet => 能够高效率的储存大量 [ / ] (开/关) 资料
HashMap => 用来取代HashTable储存 (key/value) pairs
TreeMap => 储存 (key/value) pairs会自动根据Key值排序
LinkedHashMap =>
Performance is likely to be just slightly below that of HashMap due to the added expense of maintaining the linked list with one exception: Iteration over the collectionviews of a LinkedHashMap requires time proportional to the size of the map regardless of its capacity Iteration over a HashMap is likely to be more expensive requiring time proportional to its capacity
IdentityHashMap =>
This has better locality for large tables than does using separate arrays) For many JRE implementations and operation mixes this class will yield better performance than HashMap (which uses chaining rather than linearprobing
WeakHashMap => 这个map中由于每个Value仅存在一个实体因而节省了储存空间一但程序需要某个Value便在map中搜寻既有的对象并使用找到的那个对象(而非重新再造一个)由于这是一种节省储存空间的技巧所以能够方便的让GC自动清理Key和Value一但Key不在被使用便会触发清理动作
容器简介
容器的分类
Collection一组各自独立的元素即其内的每个位置仅持有一个元素
)List以元素安插的次序来放置元素不会重新排列
)Set不接爱重复元素它会使用自己内部的一个排列机制
Map一群成对的keyvalue对象即所持有的是keyvalue pairs
Map中不能有重复的key它拥有自己的内部排列机制
容器中的元素类型都为Object从容器取得元素时必须把它转换成原来的类型