java.lang.ArrayIndexOutOfBoundsException -
i'm novice java programmer. dont know wrong main method, keeps pointing me line
int x = integer.parseint(args[0]); this code
public static void main(string[] args) { assert args.length == 1; int x = integer.parseint(args[0]); while (x != 1) { x = nextint(x); system.out.print(" " + x); } } public static int nextint(int x) { if (x % 2 == 0) { return x / 2; } else return 3 * x + 1; }
i'm going assume using number in first argument of program call.
you using asserts, verify assertions activated. execute code vm argument: -ea.
Comments
Post a Comment