I looked everywhere on the web to find a java function to calculate the mode of an array of primitive ints. This will work for floats and long ints too, I suppose.
Anyway, since it was impossible to find, I figured I would post it here so maybe someone else can benefit.
public int calcMode(int[] sourceArray) { int mode = 0; Arrays.sort(sourceArray); int[] valCounts = new int[(sourceArray.length-1)]; for(int val:sourceArray) valCounts[val]++; int i = 0; while(i < valCounts.length) { if(valCounts[i] >= valCounts[mode]) mode = i; i++; } return mode; }
Hope this helps someone!
2 Comments | 6925 days old | Direct Link
Well, here it is. My first project using AJAX. I'm very familiar with javascript, so using the AJAX methodology came very natural to me. I made this php calendar script for a customer a few months back, but it required page refreshes to load the next and previous months.
When I heard about AJAX, the calendar seemed to be a perfect project to implement using it. I've tested it in the most recent browsers, Firefox and IE 6, and both work perfectly. Enjoy!
2 Comments | 6944 days old | Direct Link
I recently started a new job as a java application developer, so I figured writing a game would be a great learning experience. I finished it up this week, so I wanted to put it out there for you to download. Click the link below to download the zip file. Just extract the exe and run it. Let me know what you think.
Click here to download the file
2 Comments | 6945 days old | Direct Link