java - run time error (ArrayOutOfBoundException) -
getting run time error arrayoutofboundexception
class command { public static void main(string[] args) { int a,b,c,sum; = integer.parseint(args[0]); b = integer.parseint(args[1]); c = integer.parseint(args[2]); sum = a+b+c; system.out.println("command line sum "+sum); } }
// error in code ?
an arrayindexoutofboundsexception
occurs when seek reference index not exist in array. here, you're implicitly assuming give programme 3 arguments (or more). if it's run no arguments, args[0]
generate exception. if it's run 1 argument, you'll exception on args[1]
, if it's run 2 arguments, args[2]
cause said exception.
java
No comments:
Post a Comment