+ 1
Why am I getting java.lang.ArrayIndexOutOfBoundsException on the 8th line and how to remove the error?
import java.io.*; class cubeC { public static void main(String args[]) { System.out.println("Please enter the number to find the cube of a digit: "); int n=Integer.parseInt(args[0]); int c=n*n*n; System.out.println("The Cube of Number is : "+c); } }
1 Antwort
+ 8
No argument was passed through to args, so most probably it does not contain any data. This means that accessing args[0] will trigger the exception.