How to convert String type to Class type in java

前端 未结 3 1055
遇见更好的自我
遇见更好的自我 2020-12-17 16:15

I want to print all the class names in a package and also to print the corresponding attributes and their data types in each package.

In one code, I am able to get t

3条回答
  •  天涯浪人
    2020-12-17 16:38

    Please try as following.

    String str = "RequiredClassName";    
    Class  Cref = Class .forName("PackageNaem."+str );
    

提交回复
热议问题