java.lang.Class.getEnclosingMethod()


java.lang.Class.getEnclosingMethod()

package com.codingdict;



import java.lang.*;



public class ClassDemo {



   public Object c;



   public ClassDemo() {

      class ClassA{};

      c = new ClassA();

   }



   public Object ClassAObject() {

      class ClassA{};

      return new ClassA( );

   }



   public static void main(String[] args) {



      Class cls;

      cls = (new ClassDemo()).ClassAObject().getClass();



      System.out.print("方法 = ");

      System.out.println(cls.getEnclosingMethod());

   }

}