I suggest you go through the flow of control like this, on a sheet of paper.java CollTest2
0
0
7
22
30
java CollTest2
0
0
7
31
47
java CollTest2
0
0
14
35
43
etc...
Mudit Agarwal wrote:hey Campbell thanks for posting on my query will definitely go through flow again..and will post the problem if it occurs again
yea actually i was writing code for something else ..code i posted is a very small part of that program,complete question i am mentioning below
Question -1- write a program (any language you want) to loop through all possible poker hands once each. Here, a “poker hand” is a list of 5 distinct numbers from 1..52, e.g. {2, 3, 7, 13, 40}. Your program should be able to generate each such array, with
the 5 numbers in ascending order.....
There are three kinds of actuaries: those who can count, and those who can't.
Mudit Agarwal wrote:. is it possible can you help with the algorithm of the problem.t
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
Pat Farrell wrote:Random number generators in nearly all languages default to using the same seed, which makes then produce the same sequence of results. If you want to get different numbers each time you run, use something that varies, like the current time, as an argument to set the seed. Its usually easier to debug your code when you have the same sequence over and over -- once its working, you then set a non-default seed.
So, using this constructor will start with a random seed, not a default seed. If you want to control the seed being used you need to use the Random(seed) constructor.public Random()
Creates a new random number generator. This constructor sets the seed of the random number generator to a value very likely to be distinct from any other invocation of this constructor.
nithatufro tufro wrote:Hey! I was doing this task with modern java and I was able to code a very simple function generateRandomInteger following this tutorial to generate random integers with java 1.7 or later.
Hope this information helps to anyone. If you don't want to follow the link and just use the function:
That tutorial is not very helpful; as well as what Carey says, it doesn't explain the potential problems with the different techniques, nor give you a recommendation about which is best. It also for some peculiar reason uses thread local random rather than java.util.Random. Yoiu will find a thorough discussion here, but of course all those discussions are out of date now the Random#ints() method and simlar methods are available.nithatufro tufro wrote:. . . this tutorial. . . .