+ 1
Random in stack
How can I pick random number in stack?
1 Answer
0
If you are talking about the âstackâ data structure then you canât. The whole point of a stack is to access the value of ONE element at a time from the âtopâ of the stack a.k.a the last element that was appended to it. So in order to pick a random number from a list of values use an array or ArrayList and use the standard random package supplied with Java.