This
for (int i = 0; i<args.length -1; ++i)
count++;
basically computes args.length
again, just incorrectly (loop condition should be i<args.length
). Why not just use args.length
(or nums.length
) directly instead?
Otherwise your code seems OK. Although it looks as though you wanted to read the input from the command line, but don't know how to convert that into an array of numbers - is this your real problem?