集合知識點

2021-10-14 15:35:38 字數 1477 閱讀 8817

1. 自然排序實現步驟

1.在泛型中的自定義類中實現comparable《自定義類名》

2.重寫compareto方法

3.建立treeset集合,向集合中新增元素

2. 定製排序實現步驟

1.編寫自定義類

2.單獨定義比較器類,實現comparator《自定義類》

3. 重寫compare方法

4.建立treeset集合,new treeset<>(new 比較器物件)

3. collections中的求最大值和最小值的方法是?

collections.max

mincollection

排序4. hashset與hashmap的關係

hahset類中有乙個屬性,hashmap

當建立hashset物件,就會建立hashmap的物件

每當set.add(e) 就會被新增到hashmap的鍵中

5. string,stringbuffer,stringbuilder的區別

string 不可變字串行 占用記憶體小, 效率低 非頻繁增刪內容

stringbuffer 字串緩衝區 佔中的記憶體大, 執行緒安全, 效率比string高 多執行緒中

stringbuilder 字串緩衝區 佔中的記憶體大, 執行緒不安全 效率比stringbuffer高

單執行緒中使用

6. 迭代器的遍歷

iterator

iterator it = llist.

iterator()

;while

(it.

hasnext()

)

7. 單例模式

class huangryinstance

//2. 建立乙個huangryinstance物件

private

static

final huangryinstance intstance =

newhuangryinstance()

;public

static huangryinstance getinstance()

}class lazyinstance

private

static lazyinstance instance=null;

public

static lazyinstance getinstatnce()

return instance ;

}}

當乙個類類名被用到的時候,去位元組碼檔案中找person的位元組碼檔案, 將他載入到方法區中,

並且將所有的靜態的屬性和方法全部載入到靜態域

person p;

集合知識點

1.集合框架中包含哪些集合 collection list arraylist linkedlist vector sethashset treeset maphashmap treemap 2.list集合與set集合的特點 list 有序並且允許重複 set 無需並且不允許重複 3.arrayl...

集合知識點歸納

集合 定義 長度可變的 儲存物件的容器 特點 長度可變,只能用來儲存引用型變數 list介面 有序的,允許重複的 實現類 arraylist 底層維護陣列,執行緒不安全的,高效的,查詢快,增刪慢 linklist 底層維護鍊錶,能夠模仿佇列結構,增刪快 查詢慢 堆疊特點 先進後出 push 將元素壓...

集合知識點總結

1.常用集合介面 a collection介面 最基本的集合介面,儲存不唯一,無序的物件,list介面和set介面的父介面 set set new treeset new comparator list weights new arraylist list是父類,作為乙個介面,也是乙個集合,是乙個集...