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 Java in General and the fly likes How can I create an array of arrays without any repetition of values? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "How can I create an array of arrays without any repetition of values?" Watch "How can I create an array of arrays without any repetition of values?" New topic
Author

How can I create an array of arrays without any repetition of values?

Shuaib Yunus
Greenhorn

Joined: Aug 13, 2011
Posts: 2
I'm trying to create a 5*3 array table that is generated with non-repeating values, but I cant seem to shuffle all the arrays efficiently without repeating values. Please help.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

First of all welcome to the Javaranch!

Something like:

Create the array.
Fill the array with number 1 through 15
start loop
get random x
get random y
get random x2
get random y2
swap(array[x][y], array[x2][y2])
end loop


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Shuaib Yunus
Greenhorn

Joined: Aug 13, 2011
Posts: 2
Thanks a lot, it was helpful. My program works perfectly.
 
Have you checked out Aspose?
 
subject: How can I create an array of arrays without any repetition of values?
 
It's not a secret anymore!