• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Util2

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What can contain objects that have a unique key field of
String type, if it is required to retrieve the objects using that
key field as an index?
A. Map ...ans
B. Set ...why not !!
C. List
D. Collection
E. Enumeration
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both Map and Set should contain only unique elements, but Map can be used for indexing purposes whereas indexing cannot be done for Set.
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Map (with the understanding that the key is an Object and not restricted to a String object).
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramana,
a small correction.Both element objects of Set and key elements of a Map are unique.
A Map can have duplicate elements with diff index keys
By the way, while testing this concept I found this. JDK doc, says entrySet() method in Map interface return type is Set. enterySet() returns the CollectionView of the elements in a Map. Further down JDK also says that, each element in the returned CollectionView is a key-value pair which is of class type Map.Entry Since the elements(not index keys) in a Map can have duplicates how come JDK says Set entrySet()? For keySet() it says the return type is Set which is convincing to me. Any clarifications..from any of you?
Thank you,
Wait a min, I think this means each key-value pair as such is considered to be unique. Then we can say it is Set
regds,
maha anna.


[This message has been edited by maha anna (edited March 04, 2000).]
reply
    Bookmark Topic Watch Topic
  • New Topic