Calculate average in java

后端 未结 10 2150
悲哀的现实
悲哀的现实 2020-12-11 07:49

EDIT: Ive written code for the average, but i dont know how to make it so that it also uses ints from my args.length rather than the array

I need to

10条回答
  •  旧时难觅i
    2020-12-11 08:14

    This

    for (int i = 0; i

    basically computes args.length again, just incorrectly (loop condition should be i). 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?

提交回复
热议问题