You could consider overriding the .equals() method of the data class.
Doing so would allow you to do the following to check for duplicate elements:
ArrayList<data> array_list = new ArrayList<data>();
// add some elements to array list
// check for duplicates
for(int i =0; i < array_list.size(); i++){
for(int j=0; j<array_list.size(); j++){
// compare for equality if it is not the same element
if(i != j){
if(array_list.get(i).equals(arrayList.get(j))){
// than we know there is a duplicate at index i,j
System.out.println("duplicate indexes: " + i + ", " + "j");
}
}
}
}
Here is an example of how you would override the .equals method of the data class.
@Override
public boolean equals(Object obj) {
if (!(obj instanceof data)){ return false; }
if (obj == this) { return true; }
// compare strings to see if they are equal
data other_data = (data)obj;
boolean id_equal = other_data.id.equals(this.id);
boolean value_equal = other_data.value.equals(this.value);
boolean status_equal = other_data.status.equals(this.status);
return id_equal && value_equal && status_equal
}
Edit
If you only want to know whether the id's are equal or not you don't need to override .equals() of the data class.
In this case you need only need to use the first loop and compare the id stings instead of the data objects.
So instead of array_list.get(i).equals(arrayList.get(j),
you would do (assuming you have getter methods for the private members of data):
array_list.get(i).get(id).equals(array_list.get(j).get(id));
Alternatively you could use a method similar to the first one and override .equals() to only compare the id strings.