• 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

3D Array of Objects

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to have a 3D Array of objects. I tried doing ArrayList inside ArrayList inside ArrayList. It didn't work, atleast for me. Can anyone help me in achieving a 3D Array of Objects?
Thanks,
- Raja.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, this works, of course:
Object[][][] my3DArray = new Object[10][10][10];
An ArrayList of ArrayLists of ArrayLists would also work, but it'd be awfully messy. Better would either be to use the above directly (if the 3D array has a fixed size) or write a wrapper class for it to encapsulate all the hairy growing and copying code.
 
Raja Kannappan
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. But, in my case all the three dimensions are of dynamic size. Also, I'll be adding the objects to my 3D array in a loop.
Can you clarify me how I can achieve this?
Thanks,
- Raja.
[ February 26, 2004: Message edited by: Raja Kannappan ]
 
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you post your code that did not work?
Ed
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic