Originally Posted by
GregBrannon
Please use standard Java terms so that we have some chance of understanding what you're asking. What's a "list array?" Do you mean ArrayList? Looking at the code, I think so, but I can't be sure what I'm looking at is what you're talking about.
The above objective statement is not clear. Again, I don't know what you mean by "empty set." A set is a collection that does not contain duplicates. Is that what you mean? Giving your variables better names would also be helpful.
It "sounds" like you're using one collection to indicate the indices of which values to collect from another collection to store in a third collection. Something like:
// method collectStrings() returns an array of Strings collected from the
// argument ArrayList stringList at the indices specified by the elements
// of the argument int[] indexArray
public String[] collectStrings( int[] indexArray, ArrayList<String> stringList )
{
String[] resultArray = new String[indexArray.length];
for ( int i = 0 ; i < indexArray.length ; i++ )
{
resultArray[i] = stringList.get( indexArray[i] );
}
return resultArray;
} // end method collectStrings()
Note that this example has no error checking.
So sorry for not being able to explain my point! Yes list array == ArrayList.
Here is exactly what I'm doing: I have an Array of type Object with some strings, I passed that array to a method where some calculations are done to group similar strings together. The output of that method is an ArrayList of type int[]. Now, I'm trying to loop through the int[] that are inside the list and then I'm using an inner loop to loop through each element of those arrays. What I want to get as a result is the strings grouped based on the indices that are in the int[].
So I tried using an ArrayList of type String, and also tried the Set of type String to store the strings instead of their indices. What I'm seeing is that my loop adds the Strings to the Set or the ArrayList and keeps on adding the new values after each loop. While what I want to achieve is just adding only the Strings of specific indices. I hope I explained myself better this time. Looking forward hearing your comments.