Here is this simple code from my book it produces error message in netbeans and in compile version (.class) version running through Command prompt.
Error Message
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at intocm.Intocm.main(Intocm.java:17)
Simple Program to convert inches to centimeter.
package intocm;
public class Intocm {
public static void main(String[] args) {
// TODO code application logic here
double inches;
inches = Double.valueOf(args[0]).doubleValue();
double cm;
cm = inches * 2.54;
System.out.println(cm + "Centimeters");
}
}
The Line which Causes error is
inches = Double.valueOf(args[0]).doubleValue();
I don't know why this array "args" causing this error please help me in understanding this.
Thank you.