Java Learning Note 33

Source: Internet
Author: User

On the set this interface, as we mentioned in the previous notes,set is an unordered, non-repeatable set, in fact set is one that does not contain duplicate elements


The collection of the vegetarian. The standard for set does not contain duplicate elements is that it does not contain element pairs that meet e1.equals (E2), elements E1, and E2. and contains up to


A null element.


Let's take a look at the method description given by this interface:


1.

int size ();
if the specified element does not already exist in the set, this element is added (optional).


2.

Boolean AddAll (collection<? extends e> c);
if all the elements in the collection are not specified in the set, they are added to this set (optional operation).


3.

void Clear ();
removes all the elements in this set (optional operation).


4.

Boolean containsall (collection<?> c);
returns trueif the set contains the specified element.


5.

Boolean containsall (collection<?> c);
returns trueif this set contains all the elements of the specified collection.


6.

Boolean equals (Object O);
compares the equality of the specified object to this set.


7.

int hashcode ();
returns the hash code value for the set.


8.

Boolean isEmpty ();
returns trueif the set contains no elements.


9.

Iterator<e> Iterator ();
returns an iterator that iterates over the elements in this set.


10.

Boolean remove (Object O);
if the specified element exists in the set, it is removed (optional action).


11.

Boolean RemoveAll (collection<?> c);
Removes the elements in the set that are contained in the specified collection (optional operation).


12.

Boolean retainall (collection<?> c);
preserves only those elements in the set that are contained in the specified collection (optional operation).


13.

int size ();
returns the number of elements in the set (its capacity).


14.

Object[] ToArray ();
returns an array that contains all the elements in the set.


15.

<T> t[] ToArray (t[] a);
returns an array containing all the elements in this set; the run-time type of the returned array is the type of the specified array.



Reprint Please specify source: http://blog.csdn.net/hai_qing_xu_kong/article/details/44204871 Emotional Control _ 









Java Learning Note 33

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.