How to generate instance name dynamically?

2019-09-17 00:22发布

问题:

I need to set the name of an instance of a class dynamically.

GetDataPoint "This Name has to be dinamically" = new GetDataPoint();

I need dynamic numbers of instances of this class GetDataPoint. Can anyone help please?

回答1:

An example:

ArrayList<GetDataPoint> data = new ArrayList<GetDataPoint>();
int amountOfData = 5;

for(int i = 0; i <= amountOfData; i++) {
data.add(new GetDataPoint());
}

Loop over the data list to retrieve the GetDataPoints.