Steve Dyke wrote:
Jeff Verdegan wrote:That logic doesn't say, "Add this element if it's not already in the list." It says, "For every element in this list that's not this object, add it."
The code I have does not do anything. It is like it never fires .
Nevertheless, the flaws I pointed out need to get fixed.
If that code is not being executed, then something that leads up to it is buggy. Looking at code that we never get to isn't going to help.
I want to create an array while looping thru my data set that has only unique location field data.
So you have some data set, and that data set may have duplicates. You want to copy that data set into an array, but without any duplictes. Yes?
The easiest way would be to put the data set into a java.util.Set, as they prevent duplicates, and then just copy the contents of that Set to your array. This way the API does the work of filtering out dupes for you.
If you can't or won't do it that way, then your code would need to look something like this: