Java Learning Collection Framework (2) < good programmer training camp >

Source: Internet
Author: User

<a href= "http://www.goodprogrammer.org/" target= "blank" >android training </a>------My Java notes and look forward to communicating with you!

1.Set interface

The set collection does not allow repeating elements, because set determines that two objects are the same not using the = = operator, but rather by the Equals method. That is, two objects cannot accept two objects by using the Equals method to return a true,set.

public class Setdemo{public static void Main (string[] args) {set<string> Set = new hashset<string> ();//Add one character String Object Set.add (New string ("ABCDE"));//Add a String object again, Set.add (new string ("ABCDE"));//The output below sees only one element of the collection System.out.println ( set);}}

2.HashSet

1) HashSet is not synchronous, multiple thread access is required to ensure synchronization through code

2) The collection element value can be null

Main methods: Principal- to-square method
Add (Object)
AddAll (Collection)
Remove (object)
RemoveAll (Collection)
Size ()
Iterator ()
ToArray ()
Clear ()
IsEmpty ()
Contain (object)
Containall (Collection)

Java Learning Collection Framework (2) < good programmer training camp >

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.