Java

Get name of current method in Java

package various;
 
public class Various {
    public static void main(String[] args) {
        System.out.println(method());
    }
    public static String method(){
        return Thread.currentThread().getStackTrace()[1].getMethodName();
    }
}

prints: method