Difference between Loading a class using ClassLoader and Class.forName

后端 未结 9 1059
梦如初夏
梦如初夏 2020-11-29 20:38

Below are 2 code snippets

The first one uses ClassLoader class to load a specified class

ClassLoader cls = ClassLoader.getSystemClassL

9条回答
  •  孤独总比滥情好
    2020-11-29 21:22

    there's also a difference when loading array-types. I think classloader.loadClass(clazz) cannot handle array-types, but Class.forName(clazz,true,classloader) can.

提交回复
热议问题