How to get the initialisation value for a Java Class reference

后端 未结 4 882
别那么骄傲
别那么骄傲 2021-01-04 09:52

I have a Class reference for an arbitrary type. How to get that type\'s initialisation value? Is there some library method for this or do I have to rol

4条回答
  •  走了就别回头了
    2021-01-04 10:26

    To check if a parameter of a Method is primitive, call isPrimitive(); ont the parameter type:

    Method m = ...;
    // to test the first parameter only:
    m.getParameterTypes()[0].isPrimitive();
    

提交回复
热议问题