Posted By:
Eelco_Cramer
Posted On:
Wednesday, June 15, 2005 03:06 AM
I don't know what it is that you are trying to archive? If you want to remove the duplicate strings you might want to use a
java.util.Set instance instead of an array. A set does not allow duplicates.
Well to answer your question:
String [] myStrings = {"a", "b", "c", "b", "d"};
Set mySet = new java.util.TreeSet();
for (int i=0; i if (mySet.add(myStrings[i]) {
// myStrings[i] is not a duplicate
} else {
// myStrings[i] is a duplicate
}
}
// now you have a Set containing only unique strings.