I'm making a small (for fun) game where virtual robots fight each other. I have an array of names of the classes of these robots, but I don't know how to load them. It's probably clearer in codes:
String[] classes={"Bot1","Bot2","Bot123"};
Object[] bots=new Object[classes.length];
for(int i=0;i<classes.length;i++){
bots[i]=UnknownFunction(classes[i]);
}
Additional details:
package Arena;
public class Bot {
public void main(String args[]){
}
public void init(){
System.out.print("Loaded");
}
}
In the main file:
bot=Class.forName("Arena.Bot").newInstance();
bot.init();
Classobject like the one you get fromString.classor do you want an instance of that class like innew String()?