arrays - Pick random from Java List [] -


i have list of 14 items use in method. wondering how can make randomly pick different items list instead of forcing selecting list number [0] etc. code in method this.

stats.list[0].clone ();  

i need like..

stats.list[randomnumber/decision].clone ();  

my list code

 list [0]  = new ped (names.getstring("idc"), "c");  list [1]  = new ped (names.getstring("id"), "d"); 

thanks ya help!

random r = new random(); int randomnum = r.nextint(sizeoflist); stats.list[randomnum].clone (); 

use random class.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -