Duplicate variables (null copy) in loop?
I've never seen this before.. I have the following code, a simple nested
loop assigning an object from one ArrayList to an object of another.
But, inside the inner loop, the object has some (not all) duplicate
variables with null values?!? What am I doing wrong?!?
The first image shows the local variable "member", a reference to an
object inside the ArrayList "members". This is the object with duplicate
variables with null values.
The second image show the other object "offer", looking like one would
expect.
Code below. Help?
public static void setMembersForOffers(ArrayList<WPMemberPost> members,
ArrayList<WPOfferPost> offers)
{
int memberCount = members.size();
int offerCount = offers.size();
for (int i=0; i<offerCount; i++)
{
WPOfferPost offer = offers.get(i);
if (offer.memberIdentifier != null)
{
for (int j=0; j<memberCount; j++)
{
WPMemberPost member = members.get(j);
String id = member.identifier; // NULL?!? (Expected "436")
if (offer.memberIdentifier.equalsIgnoreCase(id))
{
offer.member = member;
break;
}
}
}
}
}
No comments:
Post a Comment