I have a for loop that adds values to an array of objects. Say I have class B, and make a array of class B inside class A. like
B array1 = new B[10];
How can I name each object with a reference name that will look like
for(int x = 0; x<array1.length; x++){
B object+x = new Bar(int value1, int value2);
x++;
}
each time it goes through the for-loop I'm not sure how to add a number after "object" so that I can have 10 array objects like object1, object2, object3...
I want to be able to reference these saved objects inside another method in class A, without creating a new object each time, and then call a method from class B on the object.
Sorry I cant provide much code, its part of a assignment and I cant post my code.