Sunday, March 10, 2019

Get Name of the current executing method name

 public class MethodName {  
      public static void main(String[] args) {  
           String name = new Object() {  
           }.getClass().getEnclosingMethod().getName();  
           System.out.println(name);  
      }  
 }  

No comments:

Post a Comment