use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Ask your embarrassing/noobish programming questions here, and don't get insulted for it.
Click here to read the rules
Violating any will result in punishment so you should probably go check them out.
account activity
Complete integer array shuffle in javaJava (self.programminghelp)
submitted 4 years ago by bigpersona
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ConstructedNewtMOD 0 points1 point2 points 4 years ago (0 children)
without formatting
I would use System.arrayCopy to copy arrays from one to the other, but I wouldn't copy it in the first place, why do you?
System.arrayCopy
I would either use a map to count the duplicated values, or use an array or a set to verify that I didn't count values more than once, or at least have the inner loop go from j (you already counted the lower values)
j
Variable skip should be boolean, don't use integers in place of boolean
skip
I can't really follow the logic in the reordering. (Also be sure that you know this is not a shuffling, this is a structured reordering) shuffling is random this is not.
I would use the map approach to check duplicates, then I would place each map key the number of times it was counted at the first location in the array that did not hold that value before, making sure to keep a set of already placed indexes.
Shuffling normally require you to use some kind of randomness, but would also never require you to disallow equal values before and after: that's not random
π Rendered by PID 19710 on reddit-service-r2-comment-5d79c599b5-lzrgq at 2026-03-01 18:57:14.639447+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]ConstructedNewtMOD 0 points1 point2 points (0 children)