What do people use class loading for?

前端 未结 18 1516
暗喜
暗喜 2021-02-02 14:26

So, every Java text book talks about how flexible Java is since it can load classes at run time. Just cobble together a string and give it to Class.forName(), and

18条回答
  •  无人共我
    2021-02-02 15:09

    The ClassLoader is also used for non-class resources. Configuration files come to mind. Since there is a well-defined search order, it is easy to drop-in your own "log4j.xml" or "hibernate.properties", and the application will find and use it.

提交回复
热议问题