ArrayIndexOutOfBoundsException

Joined
Mar 27, 2011
Messages
2
Reaction score
0
Hello,

I'm a newbie to java. This is my program below and getting ArrayOutOfBoundsException.
Plz help me so that I new don't get this exception at the run-time.

public class UpcNumber {
public static void main(String[] args){
System.out.println("The last digit of UPC number is!");
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = Integer.parseInt(args[2]);
int d = Integer.parseInt(args[3]);
int e = Integer.parseInt(args[4]);
int f = Integer.parseInt(args[5]);
int g = Integer.parseInt(args[6]);
int h = Integer.parseInt(args[7]);
int i = Integer.parseInt(args[8]);
int j = Integer.parseInt(args[9]);
int k = Integer.parseInt(args[10]);
//int x = 0;

int x = (10 - (3*a + b + 3*c + d + 3*e + f + 3*g + h + 3*i + j + 3*k)/ 10)/ 10 ;


System.out.println("last number: " + x);
}

}


Thanks and Regards,
Looking forward to your replies.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top