• 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

Collections heirarchy

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am creating a program to store Categories and SubCategories

like main category is having subcategories and each subcategory can have subcategories like a heirarchy.

Main Category1
| |
Sub Category1 Sub Category 2
|
Sub Category 1a

I want to store this heirarchy structure in a collection can anybody explain which type of collection to use and how will i retrieve the collection.



 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

With my understanding about your problem statement i suggest you can use HashMaps where a Key,Value pair could be <MainCategory,SubCategory> Where the SubCategory is of type HashMap. That means you will result in something like this.

<MainCategory,<SubCategory,SubCategory1>>

like this. Still not clear. Take a look at this snippet.

 
reply
    Bookmark Topic Watch Topic
  • New Topic