Java Basics Review-22 (static import, variable parameters, collections Collection Tool class, set nesting)

Source: Internet
Author: User

1, at the time of the Guide package can import its static part, so that in the class to use it, you can directly use its name

For example: Map.entry access, after the class file header imports import Java.util.Map.Entry after simplification for entry.

2. You can use the modifier to return a value type method name ( parameter type ...). formal parameter name ) {}" to pass in an indeterminate number at the same time, parameters of the same parameter type. For example, when the data of an int of an indeterminate number is obtained, this method can be used to avoid writing multiple methods, which cannot be overloaded if the parameter type does not change, because the variable parameter does not determine the number of parameters. To increase the immutable parameters, you need to add them before the variable parameters in the parameter list. mutable parameters are only available after Java1.5.

3. Common methods of collections collection tools

Collections.shuffle (list<?> list)//randomly arranges the elements in the list.

Collections.sort(list<?> List)//The elements are sorted in ascending order according to their natural sequence.

4, set nesting, common nested forms:

(1) ArrayList nested ArrayList,

(2) Map nesting ArrayList

(3) Map set nesting

Java Basics Review-22 (static import, variable parameters, collections Collection Tool class, set nesting)

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.