Hi Kaushal,
String x = new String[] {"aaa","bbb","ccc","ddd","eee"} [4];
This statement is perfectly legal. Here you are creating an anonymous String array object with 5 elements and you are selecting the 5th element and assigning it to the string variable x. So after execution of this line the String variable x will be having the value eee.
After execution of this line the anonymous string array object will be eligible for garbage collection.
String x = new String[] {"aaa","bbb","ccc","ddd","eee"} [5];
Here the syntax is legal but you are trying to access the sixth element of an array which has only 5 elements. So this causes runtime error.
Hope you are clear.
Sanyev
[ July 26, 2004: Message edited by: Sanyev Babu ]