public class TestMain {
    public static void  main(String[] args){
        hello();
    }
    
    public static void hello() {
        String className = Thread.currentThread().getStackTrace()[2].getClassName();
        String methodName = Thread.currentThread().getStackTrace()[2].getMethodName();
        int lineNumber = Thread.currentThread().getStackTrace()[2].getLineNumber();
        
        System.out.println(className);
        System.out.println(methodName);
        System.out.println(lineNumber);
    }
}

 

相关文章:

  • 2022-02-07
  • 2021-12-20
  • 2021-07-08
  • 2022-12-23
  • 2021-07-11
  • 2021-12-29
  • 2021-08-16
  • 2022-12-23
猜你喜欢
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2021-04-03
  • 2022-02-07
  • 2022-12-23
  • 2021-06-05
相关资源
相似解决方案