[Groovy] HashSet and Hashtable

Source: Internet
Author: User

Hash:

HashSet set = new HashSet () Set.add ("India") Set.add ("USA") Set.add ("China") log.info "set size is:" + set.size () set.add ("C Hina ") Log.info" Set size is: "+ set.size () Iterator iter = Set.iterator (); Log.info" If have Next: "+iter.hasnext () log.in Fo Iter.next () while (Iter.hasnext ()) {Log.info iter.next ()}

Result:

Tue June 15:02:49 CST 2015:info:set size Is:3
Tue June 15:02:49 CST 2015:info:set size Is:3
Tue June 15:02:49 CST 2015:info:if has next:true
Tue June 15:02:49 CST 2015:info:usa
Tue June 15:02:49 CST 2015:info:china
Tue June 15:02:49 CST 2015:info:india

Hashtable:

Result:

Tue June 15:06:55 CST 2015:info:size of table is 4
Tue June 15:06:55 CST 2015:info:name is Henry
Tue June 15:06:55 CST 2015:info:country is Russia

[Groovy] HashSet and Hashtable

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.