Java example with ClassLoader

后端 未结 3 2045
野性不改
野性不改 2021-01-05 20:27

I have small problem. I learn java SE and find class ClassLoader. I try to use it in below code: I am trying to use URLClassLoader to dynamically load a class at runtime.

3条回答
  •  滥情空心
    2021-01-05 20:56

    You can't refer to the dynamically-loaded type by name in the code, since that has to be resolved at compile-time. You'll need to use the newInstance() function of the Class object you get back from loadClass().

提交回复
热议问题