How to generate instance name dynamically?

梦想的初衷 提交于 2019-12-12 00:09:21

问题


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.



来源:https://stackoverflow.com/questions/16171941/how-to-generate-instance-name-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!