This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I create an array of arrays without any repetition of values?
 
Similar Threads
Arrays in Java
Algoritme for searching differnce in array's
help me with array
how to realize the function as a copy constructor in java?
Playing around with 2D arrays