troubleshooting Question

randomize array of integers

Avatar of -Dman100-
-Dman100-Flag for United States of America asked on
8 Comments5 Solutions411 ViewsLast Modified:
I am trying to shuffle an array of 52 integers using the following method:

	public static List<Integer> shuffleArray(Integer[] arr) {
		Integer[] randomizedArray = new Integer[]{};
		for(Integer i=0; i<arr.size(); i++) {
			Double dbl = math.random() * arr.size();
		return randomizedArray;

I want to randomize the array so that the integers are out of order and unique.  Right now, the array is randomized, but it is not unique.  I want all the integers to be unique.  I also want to make sure the order of the array is never 0,1,2,3,4,5,6,7...etc...51.

I'm using the Salesforce apex language above, which is a derivative of Java.  I don't have access to the shuffle method and the random object.  I need to accomplish it with the above code structure.

Any help is appreciated.
Peter Kwan
Analyst Programmer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 5 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 5 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros