Java Reflection Java Java API
Class:
java.lang.reflect.Method
Method:
public boolean isDefault()
Returns
true
if this method is a default method; returns
false
otherwise. A default method is a public non-abstract instance method, that is, a non-static method with a body,
declared in an interface type.
Examples
package com.logicbig.example.method;
import java.lang.reflect.Method;
public class IsDefaultExample { private interface Task { default void asyncProcess() {}
void process(); }
public static void main(String... args) throws NoSuchMethodException { Method m = Task.class.getDeclaredMethod("process"); System.out.println(m.isDefault()); Method m2 = Task.class.getDeclaredMethod("asyncProcess"); System.out.println(m2.isDefault()); } }
Outputfalse true
|