Can a string be used as the name of an object?
No. The usual way to do this is to use one of the List implementations and add objects to it, for example:
class being{ static List<being> beings = new LinkedList<being>(); void createbeing(){ beings.add(new being()); } }
(I am not advocating using a static list of creatures. There is almost certainly a better approach to the bigger problem you are trying to solve. But that was the minimal code for the code you presented.)
Alternatively, you can use Map and actually get the names you need ( "b1" , etc.):
class being{ static int count = 0; static Map<String,being> beings = new HashMap<String,being>(); void createbeing(){ count++; beings.add("b" + count, new being()); } }
(The same caution as above)
source share