Khalid Mughal says, in Java arrays of 0 elements can be CONSTRUCTED. Suppose i declare an array as : int arr1 = new arr; This line of code compiles fine. But when executed it fires a ArrayOutOfBoundException. In such a case a question just popped up, why then allow to create an array of 0 elements. What is achieved ?? Please help me to understand this funda better, Thanx in advance, Tejas
Hi Tejas, You can create an array of length 0 if you type arr1.length, output will show you that it is 0 length. but if you try to type arr1 then it will definetely throw runtime excep. ArrayIndexOutOfBoundException as u are asking for the first element arr1 which it does not have since it is of length 0 hope it helps Regards Neha
Joined: Oct 08, 2001
thanx neha, but the thing that's bugging me is that WHY ALLOW TO CREATE array of size 0. What is achieved ???