Now, coming to your problem, an ArrayIndexOutOfBoundsException is natural because of line no. 3 and 4 of your Java code.
Please note that in Java, there are no n-dimensional (2D,3D etc.) arrays. What you are declaring is an array of arrays (and not a 2D array). In your code, you are initializing count as 0 and then passing it as size of array. So, in turn, you are creating an array of size 0. Obviously, the moment you access any element of that array, its gonna throw that typical exception.
If value of count is not known beforehand, and you are only concerned about key-value pairs (i.e. number of 'columns' is always 2), then how about using a Map (say HashMap)? That way, you don't need to declare its size during initialization.