When i tried running this code I get this error..I dont know where i went wrong..
Exception in thread \"main\" java.lang.ArrayIndexOutOfBoundsException: 0
Are you supplying a command line argument when you run it?
if (args[0] != null) n = Integer.parseInt(args[0]);
If you aren't then the above line will fail. You should check if args.length >= 1 before accessing args[0].
args[0]