By default, it uses the current time as the seed... so, the series of numbers won't be the same, since the time changes.
See Pseudorandom number generator for detailed information.
sparsh khandelwal wrote:
But if i want to make a program to generate random no. without using any function,how should i start to approach that?
The link provided by Jesper have some ideas on how to write your own. Remember, when writing one of your own, there is no exact right answer -- just test it with lots of samples, and if the distribution looks random (and even distributed) then you succeeded.
but i am a beginner in java and i need some more stuff for create random number generator,so please provide me some more stuff so that i can easily understand the thing.
thanks in advance!!!
In which case I shall move this thread.
Wouter Oet wrote:. . . It isn't something beginners . . . do. . . .
You'll need to study those and determine which one is suitable for your purposes, and then write Java code that implements your chosen algorithm.
It's not a question that you can solve in five minutes, and don't expect that someone will post the complete code here so that you don't have to put any effort into it...
sparsh khandelwal wrote:Because i am at the stage on which i not know how to take the current time as seed too.
You get the current time (in milliseconds since 1 January 1970, 00:00:00 UTC) in Java by calling System.currentTimeMillis(). Study the algorithms to understand what you're supposed to do with the seed.
sparsh khandelwal wrote:it is in compact form,i need everything in detail.!
Because i am at the stage on which i not know how to take the current time as seed too.
so please recommend me (books,notes,tutorial) which is fully dedicated to create random number generator.
I don't think you understand how we do things here. We don't hand out code. We are here to help you learn. We will answer specific questions as best we can. However, a general, overly broad "I need you to tell me everything" will not get you much of a response around here.
Do you know how to write a "hello world" application? Can you compile and run it?
Do you know how to write java code at all? Do you know how to write modular programs? Do yo know how to analyze a problem and break it down into it's components?
IMHO, getting the current time as the seed would be one of the LAST things you'd want to do. I would think you'd want to use the same seed each time during your development process, so you can see how good or bad your algorithm is.
Show us what you have so far, ask SPECIFIC and FOCUSED questions, and you'll get all kinds of help. Continue saying "Tell me everything I need to know about how to do this" will most likely be met with silence. Reply when people ask you questions. Read the articles people point you to, and acknowledge you have read them.