Java Advanced Features

Source: Internet
Author: User

1, the difference between HashMap and Hashtable:

The HashMap class is the implementation of a hash table-based MAP interface. It provides all the optional mapping operations and allows NULL values and NULL keys to be used. However, this class does not guarantee the order of the mappings, especially because it does not guarantee that the order is constant. The Hashtable class implements a hash table that maps the keys to the corresponding values. Any non-null object can be used as a key or a value. In the Java collection framework, some classes are thread-synchronized security classes, which are vectors, Hashtable, stacks, enumeration. The HashMap class is the implementation of a hash table-based MAP interface. It provides all the optional mapping operations and allows NULL values and NULL keys to be used. However, this class does not guarantee the order of the mappings, especially because it does not guarantee that the order is constant. The Hashtable class implements a hash table that maps the keys to the corresponding values. Any non-null object can be used as a key or a value. In addition, in the Java Collection framework, some classes are thread-synchronized security classes, which are vectors, Hashtable, stacks, enumeration.

2, Java.util.Random (). Nextint (10) +1), can be randomly to 9, so the output value may be 10.

3. Use the "+" operator to concatenate strings and int/double type data, and "+" to automatically convert int/double type data to string type. The int/double type data before the string type data is first calculated and then converted to string.

4, thread-safe methods are synchronous, only one access at a time, they are heavyweight objects, less efficient. For non-thread-safe classes and interfaces, programmers are required to handle thread-safety issues themselves in multi-threading.

5, the character length of each character is 1, the space character length is also 1, the English symbol character length is also 1.

Java Advanced Features

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.