java - Quick call to generate array containing number from 0 to N -


simple question here -- apis.

i want iterate through array in random order.

it easy enough to:

  1. fill list numbers 0 n
  2. shuffle list collections.shuffle
  3. use shuffled list guide array iteration.

however, wondering if step 1 (generating list of numbers 0 n) exists somewhere in prewritten code.

for instance, convenience method in guava's xyz class??

the closest thing in guava be

contiguousset.create(range.closedopen(0, n), discretedomains.integers()) 

...but, frankly, is more readable write for loop yourself.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -