What will be the output if we pass "A B C" as command line argument?
class CommandLineArg1
{
static public void main(String[] args)
{
for(int i=0;i<=args.length;i++)
{
System.out.println(args[i]);
}
}
}
/*
Output:- A
B
C
ArrayIndexOutOfBoundsException
Explanation:- If we replace "<=" with "<" then we will not get any Runtime Exception.
*/
{
static public void main(String[] args)
{
for(int i=0;i<=args.length;i++)
{
System.out.println(args[i]);
}
}
}
/*
Output:- A
B
C
ArrayIndexOutOfBoundsException
Explanation:- If we replace "<=" with "<" then we will not get any Runtime Exception.
*/
0 comments: