return an ArrayList of Integers that consist of n random numbers?

后端 未结 5 473
夕颜
夕颜 2021-01-17 05:17

How do I create the method RandomArray and let it take in an integer n and return an ArrayList of Integers that consist of n random numbers between 0 and 255.(in other words

5条回答
  •  伪装坚强ぢ
    2021-01-17 05:49

    ArrayLists work in much the same way as arrays, except they can grow (or shrink) as you want and do not support access/retrieval via the [] operator (i.e. you can't do n[i1] on an ArrayList). Instead, use its add() method to add elements to it and get() method to access elements.

提交回复
热议问题