import java.util.Arrays;
public class ClassNameHere {
public static void main(String[] args) {
String[] items = new String[]{"John","Bob","David", "Carrie", "John","Bob","Dawson"};
String [] clone = new String[items.length];
for (int i =0; i<items.length; i++) {
clone[i] = items[i]; // copying the items array to clone
}
for (int i=items.length-1; i>=0; i--) { //trying to find duplicates.
for (int j = i-1; j>=0; j--) {
if (items[i].equals(items[j])) {
}
}
}
Hi, I am currently working on my array to remove all duplicate and change it to null value and move all null value to right side. So for example, since there are "John" and "Bob" duplicate exists, this is what I expect to make: {"David", "Carrie", "John","Bob","Dawson",null,null}.
Also, you will see I am making a clone array of items because I do not want to change any value of original items.