Int rand = new Random().nextInt(); Generates a random but if I use the variable rand multiple times, it's a different number each time. How can I generate one random number and use that same number multiple times?
Yes Code: int rand = new Random().nextInt(dbmap.mapnames.size()); Location loc1 = dbmap.maps1.get(dbmap.mapnames.get(rand)); Location loc2 = dbmap.maps2.get(dbmap.mapnames.get(rand)); This gets a different item from mapnames for loc1 and loc2 right?
I want to get a random item from a list. That item can be used to get one item each from 2 other lists but I want those items to be corresponding. I don't want one item from, say, index 3 and other from 5. I want both of same index. But a random number will change their indexes. I want one random to use it 2 times.