Try to think of a multi-dimension array as an array of arrays
It's not exactly like that inside the JVM, but that's the best mental model to work with for these sorts of questions.
So, if you have
int [][] intervals = null;
then your outer-array is null, and can later be initialised with
int size = 10;
intervals = new int[size][];
Which creates an array of int[], but in that case each of the 10 inner-arrays are null.
If you want them all to be the same size (e.g. an 10 x 5 array) then do something like:
int size1 = 10;
int size2 = 5;
intervals = new int[size1][size2];
But if you want them to be different sizes then do something like:
int size = 10;
intervals = new int[size][];
intervals[0] = new int[5];
intervals[1] = new int[4];
// etc...
But all of these assume that you know how big you want your array to be before you start filling it.
If you don't know that, then you want to use a List instead - have a look at ArrayList.
Edit
I've just seen in your comment that this latter case is what you want, so ...
Try something like:
List< List<Integer> > list = new ArrayList< List<Integer> >();
for(int i=0; i<10; i++) // You would loop over whatever input you're processing
{ // but I don't know what you're doing in that part of you code
// so I'll just do it 10 times.
List<Integer> innerList = new ArrayList< Integer >();
innerList.add( 1 );
innerList.add( 2 );
innerList.add( 3 );
// etc.
list.add( innerList );
}
Alternatively, you could have:
List< int[] > which would mean using a List for the outside collection, but an array for the inner collection, if you know how long your inner collection is going to be.
List<Integer>[] which uses an array for the outer collection, and a list for the inner collection.
It really depends on exactly how your code needs to work.
List<Integer>. To simulate a two-dimensional array useList<List<Integer>>i.e. a list containing lists of Integer.