Java Reflection class get deprecated methods

Description

Java Reflection class get deprecated methods

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class Main {
   public static void main(String args[]) throws Exception {
      Class c = Class.forName("java.lang.String");
      Method[] methods = c.getDeclaredMethods();
      for (Method method : methods) {
         Annotation[] anos = method.getDeclaredAnnotations();
         for (Annotation a : anos)
            if (a.toString().contains("Deprecated"))
               System.out.println(method);
      }/*from   www. j av  a2s  .  c  o m*/

   }
}



PreviousNext

Related