Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

passing 2D collection objects into 1D collection objects

 
Ranch Hand
Posts: 842
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when, where, how, why we need to passing 2D collection objects like hashmap, hashtable, properties into 1D collection objects like arraylist, vector, hasset, sorted set etc and reading back again. What are the practical uses, advantages, disadvanages of doing it.Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sai rama krishna wrote:when, where, how, why we need to passing 2D collection objects like hashmap, hashtable, properties into 1D collection objects like arraylist, vector, hasset, sorted set etc and reading back again. What are the practical uses, advantages, disadvanages of doing it.Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance


First: the datasets that you list are NOT 2D collections, they're Maps (see java.util.Map). They have entries, each of which has a value (which can be virtually anything), and a key (which must be Comparable; or, in some cases, can be distinguished by a Comparator), which is used to identify the value.

As to passing them into regular collections: there's generally no need. Maps that implement java.util.Map have two methods: keySet(), which returns all the keys in the Map as a Set (see java.util.Set); and values(), which returns all the values in the Map as a Collection (see java.util.Collection).

Winston
 
If you're gonna buy things, buy this thing and I get a fat kickback:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic