Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Deleting duplicates in an array

807591Apr 15 2008 — edited Apr 16 2008
Hey everyone,
I have a quick question - I've been working on a program which creates a random letter array, and then sorts it, and then deletes the duplicates, while moving the rest of the letters to the left to fill the empty space in the array. I think I've got the deleteRepeats part down, but I've been struggling while working on the delete method itself. If anyone could help out I would greatly appreciate it!

(deleteRepeats method)

public static void deleteRepeats(int [] a, int size) {
int temp = a[0];
for (int i = 1; i < size; i++) {
if (temp == a[1]) {
size = delete(a,size);
}
else {
temp = a;
}
}
} // end of deleteRepeats
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 14 2008
Added on Apr 15 2008
33 comments
314 views