📜  使用 for 循环 java 代码示例生成对象

📅  最后修改于: 2022-03-11 14:52:09.448000             🧑  作者: Mango

代码示例1
// Using the range of int i we assign new objects to the List using i as the index
List objects = new ArrayList<>();
 
for (int i = 0; i < 10; i++)
{
    // Generate or get variables
    objects.add(i, new Object(variable, variable1));
}