private Object createInstance ( Class pClass , Object pParam ) { Object value ; try { // Create param and argument arrays Class [ ] param = { pParam . getClass ( ) } ; Object [ ] arg = { pParam } ; // Get constructor Constructor constructor = pClass . getDeclaredConstructor ( param ) ; // Invoke and create instance value = constructor . newInstance ( arg ) ; } catch ( Exception e ) { return null ; } return value ; }
Creates an object from the given class single argument constructor .