Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Qestion about HashSet

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Classes that implement the interfaces use different storage mechanisms.
the Hashing Supports insertion, deletion and growing the store. Indexed access is slower.
But searching is faster.
However, requires the use of unique keys for storing data elements.
Quote from chairyuan's notes
My question if two statement below
Q1 The elements in the collection are guaranteed to be unique.
Q2 The elements in the collection are accessed using a unique key.
I think both are coorect .But the Q2 is seemt to incorrect.
Pls tell me which is true?
Thank u very much!
 
Enthuware Software Support
Posts: 4590
45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by frank yang:
My question if two statement below
Q1 The elements in the collection are guaranteed to be unique.


Elements in a Set are guaranteed to be unique. Collection is a super-interface of Set. List is also a Collection and can contain duplicate values.


Q2 The elements in the collection are accessed using a unique key.


No, elements in a Map are accessed using a unique key. Elements in a collection are accesed using an Iterator. Although elements in a List can also be accessed using an index.
HTH,
Paul.
 
frank yang
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic