This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes random numbers gen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "random numbers gen" Watch "random numbers gen" New topic
Author

random numbers gen

j srinivas
Greenhorn

Joined: Apr 08, 2008
Posts: 16
well iam unable to create random numbers betn 1-100,without repetetion.
iam declaring an array to store all random numbers.
then generate an array number and compare it with array elements
but it is not getting done
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
Is there a particular reason you're not using java.util.Random.nextInt ? It's not easy to program a good RNG on your own.
Alberto Caraz
Greenhorn

Joined: Apr 27, 2007
Posts: 18
By without repetition you mean you want to randomly permute a sequence of numbers and then show them one by one? If that's the case I would recommend creating a list of numbers from 1 to n and then calling Collections.shuffle on it. Then your "ith" random number will be the "ith" element of this sequence.
 
Have you checked out Aspose?
 
subject: random numbers gen
 
It's not a secret anymore!