I'm having this
String array[] = {"test","testing again", "test"};
that i want to mark and remove duplicates. Here is the output that i need:
2x test
testing again
Can someone help me do this? I've tried with Set but it seems it doesnt recogize when a string is already inthere.
Here is my code:
Set addons = new HashSet<String>();
final String[] arr ={"test","testing again", "test"};
for (int i = 0; i < arr.length; i++) {
Log.d(TAG, "contains adding " + arr[i]);
if (addons.contains(arr[i])) {
//never enters here
Log.d(TAG, "contains " + arr[i]);
addons.remove(arr[i]);
addons.add("2 x " + arr[i]);
} else {
addons.add("1 x " + arr[i]);
}
}