Hello!
I use method forName and newInstance in class Class like this
instance = (GameFactory)(Class.forName(name).newInstance() );
Now to my question:
Assume that name is GameFactory then I want to pass a parameter to the
GameFactory constructor
like this instance = (GameFactory)(Class.forName(name).newInstance(fiel d) );
Here I pass parameter field which is an int but when I do so I get compile
error saying
F:\gameLab\GameFactory.java(15): Cannot find method 'newInstance(int)' in
'java.lang.Class'
How you any idea?
Or is it so that if I want to pass parameter I have to explicitly use new
GameFactory(field);
//Tony