I'm doing the following on my code:
double[][] temp=new double[0][2];
The program will run with no runtime exceptions. When I get the length of the temp like this temp.length it returns 0 and when I tried accessing the length of the inner arrays like this temp[0].length it always throws an ArrayIndexOutOfBoundsException. (That was only a test.)
Now I am wondering, Java did create a array with 0 length and at the same time an inner array with a length of 2 in an array with 0 length?
- Did this kind of declaration has implications on memory management?
- Will it develop complications on the coding and running the code?
- Did Java really permit this kind of declaration?
- In what sense did they permit this kind of declaration or did they just overlook this kind of situation?
- And if they permit this declaration does it also has some special uses?
I was just exploring the possibility of doing this kind of declaration and had been questioning myself if this is really permissible.
Your opinions are gladly appreciated.