Java Method .getParameterAnnotations ()

Syntax

Method.getParameterAnnotations() has the following syntax.

public Annotation [][] getParameterAnnotations()

Example

In the following code shows how to use Method.getParameterAnnotations() method.


import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
//from ww w .  j a  v  a2  s . c o m
public class Main<T> {

  <E extends RuntimeException> T genericThrow(@Deprecated T t) throws E {
    return t;
  }

  public static void main(String... args) {
    try {
      Class<?> c = Class.forName("Main");
      Method[] allMethods = c.getDeclaredMethods();
      for (Method m : allMethods) {
        Annotation[][] types = m.getParameterAnnotations();
    
      }
    } catch (ClassNotFoundException x) {
      x.printStackTrace();
    }
  }
}




















Home »
  Java Tutorial »
    java.lang.reflect »




Array
Constructor
Field
Method
Modifier
ParameterizedType
TypeVariable