How to create a 3 dimensional ArrayList


I have a one requirement i.e i want create a 3 dimensional Array List in Java and access the elements, I searched sites but all sites gave 2 dimensional only, so if any one know please tell.

Thanks and Regards


Accessing the contents of a multi-dimensional ArrayList would be cumbersome, at best, which is why you’re not finding anything.

If you need a three dimension array that can store Objects, use a standard array:

Object array = new Object[10][10];

If you still feel the need to use a multi-dimensional ArrayList, keep in mind that ArrayLists store Objects and ArrayLists are Objects:

ArrayList multiDimensionalArrayList = new ArrayList();
for( int i = 0; i < 10; ++i ) {
  ArrayList secondLevelArrayList = new ArrayList();
  multiDimensionalArrayList.add( secondLevelArrayList );
  for( int j = 0; j < 10; ++j ) {
    secondLevelArrayList.add( new ArrayList() );

If you really think about OO design then about 99% of the time you don’t need 3 dimensional array. You just need an array of Cusom Java Class. In this class, it can have multiple List/Maps. Perhaps, you should think in this approach or at least know why it needs to be 3 dimensional.

I would rather see you use a map