Refining data in java array
<p>Ok, I have reworked the question.  I was wondering what the best way to refine an array of objects would be.<br>
I have an array of objects.  These objects will be referred to as objectA and this can be seen below:</p>

<pre><code>public class objectA  {

private String ID;
private String groupID;
private String isEligable;

public String getID() 
{
    return ID;
}

public void setID(String ID) 
{
    this.ID = ID;
}

public String getgroupID() 
{
    return groupID;
}

public void setgroupID(String groupID) 
{
    this.groupID = groupID;
}

public String getIsEligable() 
{
    return isEligable;
}

public void setIsEligable(String isEligable) 
{
    this.isEligable = isEligable;
}

}
</code></pre>

<p>As you can see the object has an ID, groupID and an isEligable variable. These objects will be added to an array and there can only ever be a maximum of two objects which have the same groupID.  One where isEligable = "F" and one where isEligable = "T". What I want to do is efficiently refine the array so that the group which has 2 objects associated to it only displays the object which isEligable = "T", ie, disregard the object in the same group where isEligable = "F".   So in the below example only object 1 and 3 would be in the array:</p>

<pre><code>Public class testExample
{

objectA[] objectArray = new objectA[3]

objectA object1 = new objectA();
object1.setID = "1"
object1.setGroupID = "0001"
object1.setIsEligable = "F"

objectA object2 = new objectA();
object2.setID = "2"
object2.setGroupID = "0002"
object2.setIsEligable = "F"

objectA object3 = new objectA();
object3.setID = "3"
object3.setGroupID = "0002"
object3.setIsEligable = "T"

objectArray[0] = object1;
objectArray[1] = object2;
objectArray[2] = object3;   

}
</code></pre>

<p>I am assuming I need to sort them into a group somehow then loop round each group to determine which one (if any) where isEligable = "T" and if so add that to a new array else if none meet that criteria in the group just add the one where isEligable ="F" to the array.  </p>

<p>My issue is though that I dont know how big the new array should be.  I suppose this is where I should use an array list? though I wanted to avoid this if possible but I suppose in this case an array list makes the most sense.  I also think this seems quite costly in terms of performance?</p>

<p>Any opinions, help or guidance would be greatly appreciated.</p>

<p>Thanks.</p>