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.
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.