Dustfinger

02-22-2008, 01:05 AM

Lets say I create an array of objects.

ObjType[] objArray = new objType[10];

for (int i = 0; i < 10; i++){

objArray[i] = new objType(a,b);

}

Where a and b are integers, and objType has a constructor which adds up a and b and stores the total in an int value called total. How can I, if at all, get the value of total for individual array objects? I tried: objArray[i].total and a number of other things, but none worked. I tried to find something on this on google but I don't really know what it is exactly that I'm searching for. Is there some specific thing I need to do or have I completely misunderstood the way arrays work?

ObjType[] objArray = new objType[10];

for (int i = 0; i < 10; i++){

objArray[i] = new objType(a,b);

}

Where a and b are integers, and objType has a constructor which adds up a and b and stores the total in an int value called total. How can I, if at all, get the value of total for individual array objects? I tried: objArray[i].total and a number of other things, but none worked. I tried to find something on this on google but I don't really know what it is exactly that I'm searching for. Is there some specific thing I need to do or have I completely misunderstood the way arrays work?