You got close, getDeclaredConstructor()
returns the Constructor
object that is supposed to be used. In addition, you need to pass the String
object to the newInstance()
method of this Constructor
.
Class<HsaInterface> _tempClass = (Class<HsaInterface>) Class.forName(hsaClass); Constructor<HsaInterface> ctor = _tempClass.getDeclaredConstructor(String.class); HsaInterface hsaAdapter = ctor.newInstance(aString); hsaAdapter.executeRequestTxn(txnData);
source share