I have 2 classes. The first describes an item, and the seconds is built around an array of items of the first class.
I had learned that just creating an array of objects doesn't initialize them. So I put a for-loop in the constructor of the 2nd class to initialize all items. Yet when entering the clear() function, all elements of the list array are still null. Why is that?
class HneAnalogItem {
String description;
String unit;
float value;
HneAnalogItem(){}
}
class HneAnalogInfo
{
static final private int MAXANALOGINFOITEMS = 100;
private HneAnalogItem[] list;
HneAnalogInfo() {
list = new HneAnalogItem[MAXANALOGINFOITEMS];
for(HneAnalogItem item : list) {
item = new HneAnalogItem();
}
clear();
}
void clear() {
for(HneAnalogItem item : list) {
item.description = "";
item.unit = "";
item.value = 0;
}
}
}