Method: toString() : Method « java.lang.reflect « Java by API






Method: toString()

 


import java.lang.reflect.Method;

/**
 * Demonstrates how to get specific method information.
 * 
 * @author <a href=mailto:kraythe@arcor.de>Robert Simmons jr. (kraythe)</a>
 * @version $Revision: 1.3 $
 */
public class Main {
  public static void main(final String[] args) {
    final Method byteValueMeth;
    final Method waitMeth;
    final Method waitDetailMeth;

    try {
      byteValueMeth = Number.class.getMethod("byteValue", null);
      waitMeth = Number.class.getMethod("wait", new Class[] {});
      waitDetailMeth = Number.class.getMethod("wait", new Class[] { long.class, int.class });
    } catch (final NoSuchMethodException ex) {
      throw new RuntimeException(ex);
    }

    System.out.println("byteValueMeth = " + byteValueMeth.toString());
    System.out.println("waitMeth = " + waitMeth.toString());
    System.out.println("waitDetailMeth = " + waitDetailMeth.toString());
  }
}

   
  








Related examples in the same category

1.Method: getAnnotation(Class < MyAnno > annotationClass)
2.Method: getExceptionTypes()
3.Method: getModifiers()
4.Method: getName()
5.Method: getParameterTypes()
6.Method: getReturnType()
7.Method: invoke(Object obj, Object... args)
8.Method: setAccessible(boolean flag)
9.Method: toGenericString()