exception error in main

February 9, 2012 at 01:03:36
Specs: Windows XP
class Sum
int x;
int y;
void getNo(int x)
int X = x;
//int Y = y;
System.out.println("X:" +x);
//System.out.println("Y:" +y);
class AddAndMul
public static void main(String args[])
int a, b;
String A,B;
for(int i=0; i<=args.length; i++)
System.out.println("Enter the value:" +args[i]);
//System.out.println("Enter the 2nd value:" +args[i]);
A = args[i];
//B = args[i];
a = Integer.parseInt(A);
//b = Integer.parseInt(B);
Sum s = new Sum();
//Sum s = new Sum();

C:\Program Files\java\jdk1.5.0_05\bin>java AddAndMul 5
Enter the value:5
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at AddAndMul.main(AddAndMul.java:21)
this was my error wt i mistake i have done....

See More: exception error in main

Report •

February 9, 2012 at 05:14:50
Your args array is of length args.length; i.e. it has elements args[0] to args[args.length - 1]. You are trying to access args[args.length], which is beyond the upper bound of the array.

Report •
Related Solutions

Ask Question