there are only 2 arrays
[code:2m819rcz]int o[] = new int[2];
try{
o[3]=23;
o[1]=33;
}catch(Exception e){
System.out.println(e.getMessage());}
}
[/code:2m819rcz]
o[3] you can only do o[0] o[1]
I understand that o[3] array can have o[0], o[1], o[2] elements in it. But my question is when we use e.getMessage() method, should it return the exception name? (in this case it would be ArrayOutOfBound) or it should return the index of array? (which is exceeded and in this case it is 3). Because, right now when I use this method on this example, it returns the index i.e. 3.
Can you please clarify?
What should be the output of the following code?
public class Test {
public static void main(String[] args) {
int o[] = new int[2];
try{
o[3]=23;
o[1]=33;
}catch(Exception e){
System.out.println(e.getMessage());}
}
}
Should it be: "3"? or Should it be "ArrayOutOfBound Exception"?
Basically, my question is: what will "e.getMessage()" return in this program?