Utility of the method "java.lang.reflect.Method.getDefaultValue ()"?

What is the purpose of the getDefaultValue () method in the java.lang.reflect.Method class ?, can someone point me to a situation where this method is useful?

The description from the API method does not tell me much, I do not understand what " annotation member represented by this Method instance" is:

Returns the default value for the annotation member represented by this method instance. If the element has a primitive type, an instance of the corresponding shell type is returned. Returns null if by default no element is associated with the element or if the method instance does not represent a declared member of the annotation type.

+5
source share
1 answer

"" . :

public @interface Example {
    public String stringValue() default "string default value";
    public int intValue() default 10;
}

getDefaultValue() , . stringValue() "string default value".

+11

All Articles