Wang Liping -- Differences Between ContentValues, HashTable, and HashMap, hashmaphashtable

Source: Internet
Author: User

Wang Liping -- Differences Between ContentValues, HashTable, and HashMap, hashmaphashtable

ContentValues: A storage mechanism, key-value

Feature: key can only be of the string type, and value can only be of the basic type, not an object.

Application: insert data into the database in Common Terms

ContentValues values = new ContentValues ();
Values. put ("name", "xh ");
Values. put ("level", 5 );
SQLiteDataBase db = helper. getWritableDatabase ();....... Partial Code omitted
Db. insert ("hero_info", "id", values );

Certificate ------------------------------------------------------------------------------------------------------------------------------------------

HashMap: it is a lightweight Implementation of Hashtable (non-thread-safe implementation). They have completed the Map interface,

Features: NULL key values are allowed. Because of non-thread security, the efficiency may be higher than that of Hashtable. HashMap allows null as the key or value of an entry, whereas Hashtable does not.

Certificate ---------------------------------------------------------------------------------------------------------------------------------------------

HashTable: thread-safe Collection

Feature: null cannot be used as the key or value of an entry.

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

The hash/rehash algorithms used by Hashtable and HashMap are roughly the same, so there is no big difference in performance.





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.