Java basic knowledge related notes asList

asList (): an array for converting into a set.

Demo:

Output:

1. asList array can not be converted into a set of elements added or deleted, the method can only be used in the collection. // equivalent to a collection of more ways, it can be converted into a collection of more operations, if the collection were deleted or added after the conversion will be reported abnormal operation is not supported.

2. If an array of basic data types isList method for converting into a set, are (overall) as a conversion target, because the objects are stored in the collection.

   The output is: 1

   To the basic data types of each element in the array as an object is converted, as needed to define an array of object reference type, i.e. defined by the wrapper classes.

   The output is: 5

Published 30 original articles · won praise 15 · views 444

Guess you like

Origin blog.csdn.net/qq_40275740/article/details/104066056
Recommended