How do I fill an array with consecutive numbers

前端 未结 6 818
感情败类
感情败类 2020-12-20 12:29

I would like to fill an array using consecutive integers. I have created an array that contains as much indexes as the user enters:

Scanner in = new Scanner(         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-20 13:23

    You now have an empty array

    So you need to iterate over each position (0 to size-1) placing the next number into the array.

    for(int x=0; x

提交回复
热议问题