# createInstanceAsType

inline fun < T : Any > Class <*>. createInstanceAsType (vararg args: Any ?, isPublic: Boolean = true): T

Create an instance of Class with the given arguments and cast it to the specified type T.

#### Return

T

#### See also

createInstance
createInstanceOrNull
createInstanceAsTypeOrNull

#### Throws

NoSuchMethodException

if no suitable constructor is found.

IllegalStateException

if the instance cannot be cast to type T or if all arguments are null.

inline fun < T : Any > KClass <*>. createInstanceAsType (vararg args: Any ?, isPublic: Boolean = true): T

Create an instance of KClass.java with the given arguments and cast it to the specified type T.

#### See also

createInstanceAsType