get Current Method Name - Java java.lang

Java examples for java.lang:Exception

Description

get Current Method Name

Demo Code


//package com.java2s;

public class Main {
    public static String getCurrentMethodName() {
        StackTraceElement stack[] = (new Throwable()).getStackTrace();
        return stack[1].getMethodName();
    }/*from  w  w w.j  av  a  2s .co  m*/
}

Related Tutorials