Consider the following program
class kaushal
{
public static void main(
String args[])
{
try
{
for(int i=0;i<=args.length;i++)
{
System.out.println("\n array is : " +args[i]);
}
}
catch(Exception e)
{
System.out.println("Error is coming from out of bound ");
}
}
}
after compilin nd executing :
java kaushal 2 3 5
the output is :
array is : 2
array is : 5
array is : 3
Error is coming from out of bound
why is this exception being generated each time...can someone please explain ?