Saturday, 15 January 2011

Java Error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException" -


This is the simple code from my book that creates error messages in Netbeans and commands the compilation version (.class) version Prompt

error message

  Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: intocm.intocm.main (Intocm.java.1) at 0  < / Pre> 

Simple programs for inches to centimeters.

  Package intake; Public class intake {public static zero main (string [] AGR) // // TODO code application logic here double inch; Inch = double.valouf (args [0]). Double value (); Double cms; Cm = inch * 2.54; System.out.println (cm + "centimeter"); }}   

Error generating line

  inch = double.valouf (args [0]). Double value ();   

I do not know why this array "Args" creates this error, please help me understand it.

Thank you.

You are not running a command line argument. args [0] is expecting a command line argument.

If you are running it from the command line, try this:

  java intocm 12.0   

in eclipses

  play ---> Run configuration --- & gt; Logic tab --- & gt; Program Logic - & gt; Applicable --- & gt; Run    

No comments:

Post a Comment