• 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

basic question-

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, please let me know what does this statement mean?
Set set= new HashSet();
i can then use this..
set.add("one");
Why not create a HashSet hashSet directly from HashSet? WHy use Set object to access add()
-thanks.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Why not create a HashSet hashSet directly from HashSet? WHy use Set object to access add()


The reason to use Set is so that you can later change your implementation to use some other class that implements Set (LinkedHashSet, for example) with a minimum of fuss if you find it necessary. Flexibility is the word I'm looking for.
But you certainly can use HashSet if you'd like.
[ November 07, 2003: Message edited by: Derek Baker ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic