import
java.lang.annotation.*;
import
java.lang.reflect.Method;
class
demo {
public
void
demoMethod(String value)
{
System.out.println(
"demo method: "
+ value);
}
}
public
class
GFG {
public
static
void
main(String[] args)
{
try
{
Class classobj = demo.
class
;
Class[] parameterTypes = { String.
class
};
@SuppressWarnings
(
"unchecked"
)
Method method = classobj
.getMethod(
"demoMethod"
,
parameterTypes);
System.out.println(
"default value of demoMethod():"
+ method.getDefaultValue());
Method methodobj = demoInterface
.
class
.getDeclaredMethod(
"getValue"
);
Object defaultValue = methodobj.getDefaultValue();
System.out.println(
"default value of getValue():"
+ defaultValue);
}
catch
(Exception e) {
e.printStackTrace();
}
}
@Target
({ ElementType.METHOD })
@Retention
(RetentionPolicy.RUNTIME)
private
@interface
demoInterface {
int
getValue()
default
51
;
}
}