王立平-- ContentValues , HashTable , HashMap區別,hashmaphashtable

來源:互聯網
上載者:User

王立平-- ContentValues , HashTable , HashMap區別,hashmaphashtable

ContentValues  :是一種儲存機制,key-value

特點:key只能是string類型,value:只能是基本類型,不能是對象。

應用:常用語往資料庫中插入資料

ContentValues values = new ContentValues();
    values.put("name", "xh");
    values.put("level", 5);
     SQLiteDataBase db=helper.getWritableDatabase(); 。。。。。。。省略部分代碼
     db.insert("hero_info", "id", values);

------------------------------------------------------------------------------------------------------------------------------------------

HashMap:是Hashtable的輕量級實現(非安全執行緒的實現),他們都完成了Map介面,

特點:允許空鍵值, 由於非安全執行緒,效率上可能高於Hashtable。HashMap允許將null作為一個entry的key或者value,而Hashtable不允許。

---------------------------------------------------------------------------------------------------------------------------------------------

HashTable  :安全執行緒的Collection

特點:不允許將null作為一個entry的key或者value

----------------------------

Hashtable和HashMap採用的hash/rehash演算法都大概一樣,所以效能不會有很大的差異。





相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.