java.lang.Class.getDeclaringClass()


java.lang.Class.getDeclaringClass()

package com.codingdict;



import java.lang.reflect.*;



public class ClassDemo {



   public static void main(String[] args) {



      // class object associated with class Long

      Class cls = Long.class;



      方法[] m = cls.getMethods();

      for(int i = 0; i < m.length; i++) {



         // returns te declaring class

         Class dec = m[i].getDeclaringClass();



         // displays all methods

         System.out.println("方法 = " + m[i].toString());

         System.out.println(" Declaring class: " + dec.toString());

      }

   }

}