Why i got an array of constantly same value when i use a object of class Random to produce a series of randomly-generated value. By doing what I can avoid it? How does the class Random work behind scenes and what is the so-called seed. I am longing for your detailed explanation, please make it easy to understand since i am a novice. THX!
Since a random-generator generates it's values, they aren't as randomly as sometimes thought.
Modern systems use mouse- or keyboard-input, to generate numbers more randomly.
In most circumstances we don't need real random numbers, but something which looks like random.
Often there is a sequence of numbers generated, and this sequence is repeating itself, but after a very, very long time. A good algorithm will generate every possible value in the scope and with the same frequence. The last generated number might be the start-value, to generate the next number, which leads to the same sequence for the same startvalue, the seed.
This looks like a drawback, but you may use a value based on the time to generate the seed, leading to new sequences for every run. The same sequence might be very useful, when you compare two different implementations of an algorithm, which shall lead to the same result, but handle a lot of values, you don't like to generate manually.
Practical advice: Generate only one random = new Random () - object, and call random.next (...) on this common Object, which leads to a sequence of values.