我希望有一种方法可以创建一个类的对象,并自动为第一个对象命名为"b1"
,第二个对象命名为"b2"
,以此类推。我能否使用String
作为新对象的名称?如果可能,我该如何做?
class being {
static int count = 0;
String name;
void createbeing(){
name = "b" + Integer.toString(count);
being name = new being(); //Here I want to insert the String name as the name of the object
count++;
}
}