Java Reflection without qualified name

后端 未结 4 1833
时光取名叫无心
时光取名叫无心 2020-12-21 17:48

I am trying to do Java Reflection using Class c = Class.forName(className)

I want to pass in the className without specifying the package n

4条回答
  •  我在风中等你
    2020-12-21 18:36

    From the javadoc of java.lang.Class its not possible

    public static Class forName(String className)
                        throws ClassNotFoundException
    
    Parameters:
    className - the fully qualified name of the desired class.
    Returns:
    the Class object for the class with the specified name.
    

提交回复
热议问题