Difference between MyClass.class and Class.forName(“className”)

前端 未结 4 427
Happy的楠姐
Happy的楠姐 2021-01-05 07:25

We can get class Class object by 3 methods:

  • MyClass.class
  • obj.getClass
  • Class.forName(\"className\")

I don\'t understood the di

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-05 07:51

    One important difference is: A.class will perform loading and linking of class A. Class.forName("A") will perform loading, linking and initialization of class A.

提交回复
热议问题