Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String getCallerNoPackageClassNameMethod() {
        final StackTraceElement el = Thread.currentThread().getStackTrace()[2];
        final String noPackageClassName = el.getClassName().replaceAll(".*\\.", "");
        final String methodName = el.getMethodName();
        final String retval = noPackageClassName + "." + methodName;
        return retval;

    }

    public static String getMethodName() {
        return Thread.currentThread().getStackTrace()[1].getMethodName();
    }
}