Class.forname(“name”).newInstance() vs name.class.newInstance : Difference in usage perspective
问题 I will start with my example: I have a class classload.Loadable . package classload; public class Loadable { static{ System.out.println("Loaded already....."); } public Loadable(){ System.out.println("Now created....."); } } which will be loaded and created instance in the following 2 ways. First: public static void main(String[] args) throws Exception { System.out.println("Starting ....."); Class.forName("classload.Loadable").newInstance(); } Second: public static void main(String[] args)